From db81451083389a7e00c847eecf90855751d94eda Mon Sep 17 00:00:00 2001 From: James G Sack Date: Mon, 26 Nov 2007 01:15:56 +0000 Subject: [PATCH] make date_test regrtest-compatible, minor tweak to regrtest svn: r9404 --- ChangeLog | 4 ++++ src/gen/lib/test/date_test.py | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4156086a..5d65d0d7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-11-25 Jim Sack + * src/gen/lib/test/date_test.py : make regrtest-compatible + * src/test/regrtest.py : add rsplit("/") + 2007-11-25 Benny Malengier * src/gen/lib/notetype.py: type report, citation * src/plugins/NarrativeWeb.py: new selection of home note & home media diff --git a/src/gen/lib/test/date_test.py b/src/gen/lib/test/date_test.py index 6fd8ba8ab..518434ca2 100644 --- a/src/gen/lib/test/date_test.py +++ b/src/gen/lib/test/date_test.py @@ -30,7 +30,8 @@ from test import test_util test_util.path_append_parent() import Config -import date +from gen.lib import date +##import date from DateHandler import parser as df class Tester(unittest.TestCase): @@ -60,7 +61,11 @@ class Tester(unittest.TestCase): self.assertTrue(val == expected2, "'%s' and '%s' did not match" % (d2, d1)) -if __name__ == "__main__": +def suite(): + """ interface to automated test runner test/regrtest.py """ + Config.set(Config.DATE_BEFORE_RANGE, 9999) + Config.set(Config.DATE_AFTER_RANGE, 9999) + Config.set(Config.DATE_ABOUT_RANGE, 10) # most are symmetric: #date1, date2, does d1 match d2? does d2 match d1? tests = [("before 1960", "before 1961", True), ("before 1960", "before 1960", True), @@ -125,13 +130,13 @@ if __name__ == "__main__": "before 14 Thermidor 190 (French Republican)", False), ("ab cd", "54 ab cd 2000", True, False), ] - Config.set(Config.DATE_BEFORE_RANGE, 9999) - Config.set(Config.DATE_AFTER_RANGE, 9999) - Config.set(Config.DATE_ABOUT_RANGE, 10) - suite = unittest.TestSuite() + suite = unittest.TestSuite() count = 1 for test in tests: suite.addTest(Tester('test_match%04d' % count, 1, test)) suite.addTest(Tester('test_match%04d' % count, 2, test)) count += 1 - unittest.TextTestRunner().run(suite) + return suite + +if __name__ == "__main__": + unittest.TextTestRunner().run(suite())