← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~lifeless/launchpad/doctest into lp:launchpad/devel

 

Robert Collins has proposed merging lp:~lifeless/launchpad/doctest into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


Prep work for parallel testing. One of the main components of parallel testing is programmatic rearrangement of the tests to run, and story tests in particular were a problem.

Previously the test *id* for the whole story was pagetest: relname. This is ok, but I've changed it to story- to make it more clear that this is for *stories*, not just pagetests.

And now the problem bit: the delegated tests were reporting their own ids; those ids don't exist (naturally, the story appearing as a single test so it can't be split hides the components) - and even if they did exist in the full test list, they can't be run separately.

So this branch changes the ids of the individual doctests so that they all claim to be the story as far as subunit and testr is concerned. This makes the full test list able to be partitioned and parallel tested without skipping tests, and while we can make do when starting with a fresh test list(an unrun test list has the story ids), we need to be able to feed data from test runs back into the split algorithm so that we can take advantage of test performance data to make the partitions perform equally.

The downside is that when a test fails, the test *id* won't specify the exact text file for stories (01-foo-bar.txt). OTOH we're removing those incrementally, and the filename in the detailed error page will be correct. So its not a big deal IMO.
-- 
https://code.launchpad.net/~lifeless/launchpad/doctest/+merge/38182
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/doctest into lp:launchpad/devel.
=== modified file 'lib/canonical/launchpad/mail/ftests/test_stub.py'
--- lib/canonical/launchpad/mail/ftests/test_stub.py	2010-10-04 19:50:45 +0000
+++ lib/canonical/launchpad/mail/ftests/test_stub.py	2010-10-12 05:43:43 +0000
@@ -5,7 +5,6 @@
 
 from doctest import DocTestSuite
 import re
-import unittest
 
 from zope.testing.renormalizing import RENormalizing
 
@@ -114,6 +113,3 @@
         (re.compile(r'Revision="\d+"'), 'Revision="1999"')]))
     suite.layer = LaunchpadFunctionalLayer
     return suite
-
-if __name__ == '__main__':
-    unittest.main(test_suite())

=== modified file 'lib/canonical/launchpad/mail/tests/test_commands.py'
--- lib/canonical/launchpad/mail/tests/test_commands.py	2010-08-20 20:31:18 +0000
+++ lib/canonical/launchpad/mail/tests/test_commands.py	2010-10-12 05:43:43 +0000
@@ -2,14 +2,7 @@
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 from doctest import DocTestSuite
-import unittest
 
 
 def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(DocTestSuite('canonical.launchpad.mail.commands'))
-    return suite
-
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+    return DocTestSuite('canonical.launchpad.mail.commands')

=== modified file 'lib/canonical/launchpad/mail/tests/test_handlers.py'
--- lib/canonical/launchpad/mail/tests/test_handlers.py	2010-10-04 19:50:45 +0000
+++ lib/canonical/launchpad/mail/tests/test_handlers.py	2010-10-12 05:43:43 +0000
@@ -114,7 +114,3 @@
     suite.addTests(DocTestSuite('canonical.launchpad.mail.handlers'))
     suite.addTests(unittest.TestLoader().loadTestsFromName(__name__))
     return suite
-
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')

=== modified file 'lib/canonical/launchpad/mail/tests/test_helpers.py'
--- lib/canonical/launchpad/mail/tests/test_helpers.py	2010-10-04 19:50:45 +0000
+++ lib/canonical/launchpad/mail/tests/test_helpers.py	2010-10-12 05:43:43 +0000
@@ -223,7 +223,6 @@
 
 
 def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTests(DocTestSuite('canonical.launchpad.mail.handlers'))
+    suite = DocTestSuite('canonical.launchpad.mail.handlers')
     suite.addTests(unittest.TestLoader().loadTestsFromName(__name__))
     return suite

=== modified file 'lib/canonical/launchpad/mail/tests/test_incoming.py'
--- lib/canonical/launchpad/mail/tests/test_incoming.py	2010-10-04 19:50:45 +0000
+++ lib/canonical/launchpad/mail/tests/test_incoming.py	2010-10-12 05:43:43 +0000
@@ -78,11 +78,6 @@
 
 
 def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.TestLoader().loadTestsFromName(__name__))
+    suite = unittest.TestLoader().loadTestsFromName(__name__)
     suite.addTest(DocTestSuite('canonical.launchpad.mail.incoming'))
     return suite
-
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')

=== modified file 'lib/canonical/launchpad/scripts/tests/test_rundoctests.py'
--- lib/canonical/launchpad/scripts/tests/test_rundoctests.py	2010-08-20 20:31:18 +0000
+++ lib/canonical/launchpad/scripts/tests/test_rundoctests.py	2010-10-12 05:43:43 +0000
@@ -19,7 +19,3 @@
         'canonical.launchpad.scripts.logger', tearDown=tearDown
         ))
     return suite
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
-

=== modified file 'lib/canonical/launchpad/testing/pages.py'
--- lib/canonical/launchpad/testing/pages.py	2010-10-04 20:46:55 +0000
+++ lib/canonical/launchpad/testing/pages.py	2010-10-12 05:43:43 +0000
@@ -848,7 +848,7 @@
         return self._suite.countTestCases()
 
     def shortDescription(self):
-        return "pagetest: %s" % self._description
+        return self._description
 
     def id(self):
         return self.shortDescription()
@@ -910,20 +910,27 @@
     numberedfilenames = sorted(numberedfilenames)
     unnumberedfilenames = sorted(unnumberedfilenames)
 
+    suite = unittest.TestSuite()
+    checker = SpecialOutputChecker()
     # Add unnumbered tests to the suite individually.
-    checker = SpecialOutputChecker()
-    suite = LayeredDocFileSuite(
-        package=package, checker=checker, stdout_logging=False,
-        layer=PageTestLayer, setUp=setUp,
-        *[os.path.join(storydir, filename)
-          for filename in unnumberedfilenames])
+    if unnumberedfilenames:
+        suite.addTest(LayeredDocFileSuite(
+            package=package, checker=checker, stdout_logging=False,
+            layer=PageTestLayer, setUp=setUp,
+            *[os.path.join(storydir, filename)
+              for filename in unnumberedfilenames]))
 
     # Add numbered tests to the suite as a single story.
-    storysuite = LayeredDocFileSuite(
-        package=package, checker=checker, stdout_logging=False,
-        setUp=setUp,
-        *[os.path.join(storydir, filename)
-          for filename in numberedfilenames])
-    suite.addTest(PageStoryTestCase(stripped_storydir, storysuite))
+    if numberedfilenames:
+        storysuite = LayeredDocFileSuite(
+            package=package, checker=checker, stdout_logging=False,
+            setUp=setUp,
+            *[os.path.join(storydir, filename)
+              for filename in numberedfilenames])
+        story_test_id = "story-%s" % stripped_storydir
+        get_id = lambda: story_test_id
+        for test in storysuite:
+            test.id = get_id
+        suite.addTest(PageStoryTestCase(story_test_id, storysuite))
 
     return suite

=== modified file 'lib/canonical/launchpad/tests/test_datetimeutils.py'
--- lib/canonical/launchpad/tests/test_datetimeutils.py	2010-08-20 20:31:18 +0000
+++ lib/canonical/launchpad/tests/test_datetimeutils.py	2010-10-12 05:43:43 +0000
@@ -2,16 +2,9 @@
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 from doctest import DocTestSuite
-import unittest
 
 from canonical.launchpad import datetimeutils
 
 
 def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(DocTestSuite(datetimeutils))
-    return suite
-
-if __name__ == '__main__':
-    unittest.TextTestRunner().run(test_suite())
-
+    return DocTestSuite(datetimeutils)

=== modified file 'lib/canonical/launchpad/tests/test_helpers.py'
--- lib/canonical/launchpad/tests/test_helpers.py	2010-10-04 19:50:45 +0000
+++ lib/canonical/launchpad/tests/test_helpers.py	2010-10-12 05:43:43 +0000
@@ -319,7 +319,3 @@
     suite.addTest(
         unittest.TestLoader().loadTestsFromTestCase(TestEmailPeople))
     return suite
-
-if __name__ == '__main__':
-    unittest.TextTestRunner().run(test_suite())
-

=== modified file 'lib/canonical/launchpad/webapp/tests/test_publisher.py'
--- lib/canonical/launchpad/webapp/tests/test_publisher.py	2010-08-20 20:31:18 +0000
+++ lib/canonical/launchpad/webapp/tests/test_publisher.py	2010-10-12 05:43:43 +0000
@@ -5,7 +5,6 @@
     DocTestSuite,
     ELLIPSIS,
     )
-import unittest
 
 from canonical.launchpad.webapp import publisher
 
@@ -13,7 +12,3 @@
 def test_suite():
     suite = DocTestSuite(publisher, optionflags=ELLIPSIS)
     return suite
-
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')

=== modified file 'lib/canonical/testing/tests/test_doctestcodec.py'
--- lib/canonical/testing/tests/test_doctestcodec.py	2010-07-14 14:11:15 +0000
+++ lib/canonical/testing/tests/test_doctestcodec.py	2010-10-12 05:43:43 +0000
@@ -7,12 +7,8 @@
 __all__ = []
 
 from doctest import DocTestSuite
-import unittest
 
 import canonical.testing.doctestcodec
 
 def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(DocTestSuite(canonical.testing.doctestcodec))
-    return suite
-
+    return DocTestSuite(canonical.testing.doctestcodec)

=== modified file 'lib/canonical/tests/test_base.py'
--- lib/canonical/tests/test_base.py	2010-07-14 14:11:15 +0000
+++ lib/canonical/tests/test_base.py	2010-10-12 05:43:43 +0000
@@ -2,14 +2,8 @@
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 from doctest import DocTestSuite
-import unittest
 import canonical.base
 
 def test_suite():
     suite = DocTestSuite(canonical.base)
     return suite
-
-if __name__ == "__main__":
-    DEFAULT = test_suite()
-    unittest.main(defaultTest='DEFAULT')
-

=== modified file 'lib/canonical/tests/test_encoding.py'
--- lib/canonical/tests/test_encoding.py	2010-07-14 14:11:15 +0000
+++ lib/canonical/tests/test_encoding.py	2010-10-12 05:43:43 +0000
@@ -2,14 +2,9 @@
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 from doctest import DocTestSuite, ELLIPSIS
-import unittest
 
 import canonical.encoding
 
 def test_suite():
     suite = DocTestSuite(canonical.encoding, optionflags=ELLIPSIS)
     return suite
-
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')

=== modified file 'lib/canonical/widgets/ftests/test_widget_doctests.py'
--- lib/canonical/widgets/ftests/test_widget_doctests.py	2010-10-04 19:50:45 +0000
+++ lib/canonical/widgets/ftests/test_widget_doctests.py	2010-10-12 05:43:43 +0000
@@ -13,7 +13,3 @@
     suite.addTest(doctest.DocTestSuite('canonical.widgets.textwidgets'))
     suite.addTest(doctest.DocTestSuite('canonical.widgets.date'))
     return suite
-
-if __name__ == '__main__':
-    default_test = test_suite()
-    unittest.main('default_test')