Skip to content

Commit

Permalink
Convert is_directory back to a normal method instead of a property
Browse files Browse the repository at this point in the history
  • Loading branch information
albertyw committed Feb 15, 2017
1 parent ace9974 commit 87a021a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions git_browse/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_url(self, focus_object):
)
if focus_object.is_root():
return self.root_url(repository_url, focus_object)
if focus_object.is_directory:
if focus_object.is_directory():
return self.directory_url(repository_url, focus_object)
return self.file_url(repository_url, focus_object)

Expand Down Expand Up @@ -93,7 +93,6 @@ def __init__(self, path):
def is_root(self):
return self.path == os.sep

@property
def is_directory(self):
return self.path[-1] == os.sep

Expand Down
10 changes: 5 additions & 5 deletions git_browse/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def test_is_not_root(self):

def test_is_directory(self):
obj = browse.FocusObject('/asdf/')
self.assertTrue(obj.is_directory)
self.assertTrue(obj.is_directory())

def test_is_not_directory(self):
obj = browse.FocusObject('/asdf')
self.assertFalse(obj.is_directory)
self.assertFalse(obj.is_directory())

def test_default(self):
obj = browse.FocusObject.default()
Expand Down Expand Up @@ -164,20 +164,20 @@ def test_default_focus_object(self):
sys_argv = ['asdf']
focus_object = browse.get_focus_object(sys_argv, os.getcwd())
self.assertTrue(focus_object.is_root())
self.assertTrue(focus_object.is_directory)
self.assertTrue(focus_object.is_directory())

def test_file_focus_object(self):
sys_argv = ['asdf', 'README.md']
focus_object = browse.get_focus_object(sys_argv, os.getcwd())
self.assertFalse(focus_object.is_root())
self.assertFalse(focus_object.is_directory)
self.assertFalse(focus_object.is_directory())
self.assertEqual(focus_object.path[-9:], 'README.md')

def test_directory_focus_object(self):
sys_argv = ['asdf', '.']
focus_object = browse.get_focus_object(sys_argv, os.getcwd())
self.assertFalse(focus_object.is_root())
self.assertTrue(focus_object.is_directory)
self.assertTrue(focus_object.is_directory())

def test_nonexistend_focus_object(self):
sys_argv = ['asdf', 'asdf']
Expand Down

0 comments on commit 87a021a

Please sign in to comment.