Skip to content

Commit

Permalink
Add tests for help()
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Cooke committed May 17, 2017
1 parent b6ae2f9 commit 14f947e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 0 additions & 2 deletions see/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ def match(self, obj, attrs):
if '__doc__' in attrs:
lstrip = getattr(obj.__doc__, 'lstrip', False)
return lstrip and any(lstrip())
else:
return False


FEATURES = compact(tuple, (
Expand Down
26 changes: 26 additions & 0 deletions tests/test_see.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ def dajsgkljsdgklajsdgkljdsgkldsjaglkjasdgkldajsgkl(self):
pass


class ObjectWithDocstring(object):
"""
Hello, world
"""
pass


class ObjectWithEmptyDocstring(object):
"""
"""
pass


class TestSee(unittest.TestCase):

def test_see_with_no_args(self):
Expand Down Expand Up @@ -98,6 +111,19 @@ def test_see_justify_attributes(self):
self.assertTrue(all(int(factor) == factor for factor in factors),
'Irregular column widths')

def test_see_object_has_help(self):
# Arrange
obj_help = ObjectWithDocstring()
obj_nohelp = ObjectWithEmptyDocstring()

# Act
out_help = see.see(obj_help)
out_nohelp = see.see(obj_nohelp)

# Assert
self.assertTrue('help()' in out_help)
self.assertFalse('help()' in out_nohelp)


if __name__ == '__main__':
unittest.main()

0 comments on commit 14f947e

Please sign in to comment.