jenkins-bot has submitted this change and it was merged.
Change subject: Progressing dots to show test is running ......................................................................
Progressing dots to show test is running
- register all tests in different instances and run them separately
Change-Id: I30a7256f2b87e7e8a348731526e2d36b42a86f9a --- M tests/date_tests.py 1 file changed, 34 insertions(+), 20 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/date_tests.py b/tests/date_tests.py index 730c5b3..835f38b 100644 --- a/tests/date_tests.py +++ b/tests/date_tests.py @@ -13,31 +13,45 @@ class TestDate(unittest.TestCase): """Test cases for date library"""
- def testMapEntry(self): - """Test the validity of the pywikibot.date format maps.""" - for formatName in date.formats: - step = 1 - if formatName in date.decadeFormats: - step = 10 - predicate, start, stop = date.formatLimits[formatName] + def __init__(self, formatname): + super(TestDate, self).__init__() + self.formatname = formatname
- for code, convFunc in date.formats[formatName].items(): - for value in range(start, stop, step): - self.assertTrue( - predicate(value), - "date.formats['%(formatName)s']['%(code)s']:\n" - "invalid value %(value)d" % locals()) + def testMapEntry(self, formatname): + """The test ported from date.py""" + step = 1 + if formatname in date.decadeFormats: + step = 10 + predicate, start, stop = date.formatLimits[formatname]
- newValue = convFunc(convFunc(value)) - self.assertEqual( - newValue, value, - "date.formats['%(formatName)s']['%(code)s']:\n" - "value %(newValue)d does not match %(value)s" - % locals()) + for code, convFunc in date.formats[formatname].items(): + for value in range(start, stop, step): + self.assertTrue( + predicate(value), + "date.formats['%(formatname)s']['%(code)s']:\n" + "invalid value %(value)d" % locals()) + + newValue = convFunc(convFunc(value)) + self.assertEqual( + newValue, value, + "date.formats['%(formatname)s']['%(code)s']:\n" + "value %(newValue)d does not match %(value)s" + % locals()) + + def runTest(self): + """method called by unittest""" + self.testMapEntry(self.formatname) + + +def suite(): + """Setup the test suite and register all test to different instances""" + suite = unittest.TestSuite() + suite.addTests(TestDate(formatname) for formatname in date.formats) + return suite
if __name__ == '__main__': try: - unittest.main() + unittest.TextTestRunner().run(suite()) except SystemExit: pass
pywikibot-commits@lists.wikimedia.org