Skip to content

Commit

Permalink
Use inspect.getdoc rather than assuming __doc__
Browse files Browse the repository at this point in the history
This means that the tests are testing what a user will
actually see.
  • Loading branch information
timj committed Sep 14, 2023
1 parent 2a0ccc3 commit 72bf1bf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/test_inheritDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ class InheritDocTestCase(unittest.TestCase):
def test_no_inheritdoc(self):
self.assertIsNone(NoInheritDoc.method2.__doc__)
self.assertEqual(inspect.getdoc(NoInheritDoc.method2), "Return Method 2.")
self.assertIsNone(inspect.getdoc(NoInheritDoc.method5))

def test_inheritDoc(self):
self.assertEqual(
InheritDoc.method1.__doc__,
inspect.getdoc(InheritDoc.method1),
"""Return Method 1.
A note.
Expand All @@ -107,14 +108,14 @@ def test_inheritDoc(self):
New line.""",
)
self.assertEqual(
InheritDoc.method2.__doc__,
inspect.getdoc(InheritDoc.method2),
"""Return Method 2.
Note on method 2.""",
)
self.assertEqual(InheritDoc.method3.__doc__, "Note on method 3.")
self.assertEqual(InheritDoc.method4.__doc__, "Return Method 4.")
self.assertIsNone(InheritDoc.method5.__doc__)
self.assertEqual(inspect.getdoc(InheritDoc.method3), "Note on method 3.")
self.assertEqual(inspect.getdoc(InheritDoc.method4), "Return Method 4.")
self.assertIsNone(inspect.getdoc(InheritDoc.method5))


if __name__ == "__main__":
Expand Down

0 comments on commit 72bf1bf

Please sign in to comment.