test refactor

svn: r23391
This commit is contained in:
Vassilii Khachaturov 2013-10-25 08:22:01 +00:00
parent 6f2a43877d
commit 6c49da9b4b

View File

@ -269,7 +269,8 @@ class ParserDateTest(BaseDateTest):
# MatchDateTest # MatchDateTest
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@unittest.skipIf(_dd.__class__ != DateDisplayEn, ENGLISH_DATE_HANDLER = (_dd.__class__ == DateDisplayEn)
@unittest.skipUnless(ENGLISH_DATE_HANDLER,
"This test of Date() matching logic can only run in English locale.") "This test of Date() matching logic can only run in English locale.")
class MatchDateTest(BaseDateTest): class MatchDateTest(BaseDateTest):
""" """
@ -349,14 +350,17 @@ class MatchDateTest(BaseDateTest):
("1234-01-04", "1234-01-04 (Mar25)", True), ("1234-01-04", "1234-01-04 (Mar25)", True),
] ]
def convert_to_date(self, d):
return d if isinstance(d,Date) else _dp.parse(d)
def do_test(self, d1, d2, expected1, expected2=None): def do_test(self, d1, d2, expected1, expected2=None):
""" """
Tests two Gramps dates to see if they match. Tests two Gramps dates to see if they match.
""" """
if expected2 is None: if expected2 is None:
expected2 = expected1 expected2 = expected1
date1 = _dp.parse(d1) date1 = self.convert_to_date(d1)
date2 = _dp.parse(d2) date2 = self.convert_to_date(d2)
result = date2.match(date1) result = date2.match(date1)
self.assertEqual(result, expected1, self.assertEqual(result, expected1,