2007-11-25 Douglas S.Blank <dblank@cs.brynmawr.edu>
* src/gen/lib/test/date_test.py: turned each test into a case svn: r9400
This commit is contained in:
parent
8212127ecf
commit
36c73d38b3
@ -1,3 +1,6 @@
|
|||||||
|
2007-11-25 Douglas S.Blank <dblank@cs.brynmawr.edu>
|
||||||
|
* src/gen/lib/test/date_test.py: turned each test into a case
|
||||||
|
|
||||||
2007-11-24 Benny Malengier <benny.malengier@gramps-project.org>
|
2007-11-24 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
* src/GrampsWidgets.py: ObjEntry, PlaceEntry and NoteEntry inherit from it.
|
* src/GrampsWidgets.py: ObjEntry, PlaceEntry and NoteEntry inherit from it.
|
||||||
|
|
||||||
|
@ -32,8 +32,12 @@ test_util.path_append_parent()
|
|||||||
import date
|
import date
|
||||||
from DateHandler import parser as df
|
from DateHandler import parser as df
|
||||||
|
|
||||||
class Test_top(unittest.TestCase):
|
class Tester(unittest.TestCase):
|
||||||
def helper_match(self, d1, d2, expected1, expected2 = None):
|
def __init__(self, method_name, part, testdata):
|
||||||
|
self.__dict__[method_name + ("-%d" % part)] = lambda: self.helper(part, *testdata)
|
||||||
|
unittest.TestCase.__init__(self, method_name + ("-%d" % part))
|
||||||
|
|
||||||
|
def helper(self, part, d1, d2, expected1, expected2 = None):
|
||||||
"""
|
"""
|
||||||
Tests two GRAMPS dates to see if they match.
|
Tests two GRAMPS dates to see if they match.
|
||||||
"""
|
"""
|
||||||
@ -47,12 +51,15 @@ class Test_top(unittest.TestCase):
|
|||||||
pos2 = 0
|
pos2 = 0
|
||||||
date1 = df.parse(d1)
|
date1 = df.parse(d1)
|
||||||
date2 = df.parse(d2)
|
date2 = df.parse(d2)
|
||||||
|
if part == 1:
|
||||||
val = date2.match(date1)
|
val = date2.match(date1)
|
||||||
self.assertTrue(val == expected1, "'%s' and '%s' did not match" % (d1, d2))
|
self.assertTrue(val == expected1, "'%s' and '%s' did not match" % (d1, d2))
|
||||||
|
else:
|
||||||
val = date1.match(date2)
|
val = date1.match(date2)
|
||||||
self.assertTrue(val == expected2, "'%s' and '%s' did not match" % (d2, d1))
|
self.assertTrue(val == expected2, "'%s' and '%s' did not match" % (d2, d1))
|
||||||
|
|
||||||
def test_function_match(self):
|
|
||||||
|
if __name__ == "__main__":
|
||||||
# most are symmetric: #date1, date2, does d1 match d2? does d2 match d1?
|
# most are symmetric: #date1, date2, does d1 match d2? does d2 match d1?
|
||||||
tests = [("before 1960", "before 1961", True),
|
tests = [("before 1960", "before 1961", True),
|
||||||
("before 1960", "before 1960", True),
|
("before 1960", "before 1960", True),
|
||||||
@ -117,11 +124,10 @@ class Test_top(unittest.TestCase):
|
|||||||
"before 14 Thermidor 190 (French Republican)", False),
|
"before 14 Thermidor 190 (French Republican)", False),
|
||||||
("ab cd", "54 ab cd 2000", True, False),
|
("ab cd", "54 ab cd 2000", True, False),
|
||||||
]
|
]
|
||||||
|
suite = unittest.TestSuite()
|
||||||
for testdata in tests:
|
count = 1
|
||||||
self.helper_match(*testdata)
|
for test in tests:
|
||||||
|
suite.addTest(Tester('test_match%04d' % count, 1, test))
|
||||||
if __name__ == "__main__":
|
suite.addTest(Tester('test_match%04d' % count, 2, test))
|
||||||
unittest.main()
|
count += 1
|
||||||
|
unittest.TextTestRunner().run(suite)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user