From 14f947e966d6832bc4f7ec75954210a06c87171e Mon Sep 17 00:00:00 2001 From: Liam Cooke Date: Wed, 17 May 2017 21:20:48 +1000 Subject: [PATCH] Add tests for help() --- see/features.py | 2 -- tests/test_see.py | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/see/features.py b/see/features.py index 975b90c..068c3b8 100644 --- a/see/features.py +++ b/see/features.py @@ -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, ( diff --git a/tests/test_see.py b/tests/test_see.py index 7763348..4f1f9a7 100644 --- a/tests/test_see.py +++ b/tests/test_see.py @@ -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): @@ -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()