← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/launchpad/sensible-test-ids-for-doctests into lp:launchpad

 

Gavin Panella has proposed merging lp:~allenap/launchpad/sensible-test-ids-for-doctests into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #682771 in Launchpad itself: "test runner permits duplicate test ids"
  https://bugs.launchpad.net/launchpad/+bug/682771

For more details, see:
https://code.launchpad.net/~allenap/launchpad/sensible-test-ids-for-doctests/+merge/55959

>From a new comment in LayeredDocFileSuite:

  DocFileTest insists on using the basename of the file as the test
  ID. This causes conflicts when two doctests have the same filename,
  so we patch the id() method on the test cases.

This branch does not fix the related bug - it does not modify the test
runner - but it does alleviate the symptoms. Something like this is
needed before the linked bug can be fixed in any case.

-- 
https://code.launchpad.net/~allenap/launchpad/sensible-test-ids-for-doctests/+merge/55959
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/sensible-test-ids-for-doctests into lp:launchpad.
=== modified file 'lib/canonical/launchpad/testing/systemdocs.py'
--- lib/canonical/launchpad/testing/systemdocs.py	2011-02-17 16:38:15 +0000
+++ lib/canonical/launchpad/testing/systemdocs.py	2011-04-01 16:05:27 +0000
@@ -136,6 +136,16 @@
     suite = doctest.DocFileSuite(*args, **kw)
     if layer is not None:
         suite.layer = layer
+
+    # DocFileTest insists on using the basename of the file as the test
+    # ID. This causes conflicts when two doctests have the same filename, so
+    # we patch the id() method on the test cases.
+    for test in suite:
+        # DocFileTest is a function that returns a DocFileCase.
+        if isinstance(test, doctest.DocFileCase):
+            # DocFileCase.__repr__ returns the test filename.
+            test.id = test.__repr__
+
     return suite