From e7d7f1bf7224740c45e6766de6217f3b0b33fcb1 Mon Sep 17 00:00:00 2001 From: Konstantin Ermakov Date: Wed, 20 Dec 2017 15:02:30 +0300 Subject: [PATCH] add dates_not_equal method --- seismograph/case.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/seismograph/case.py b/seismograph/case.py index 409b9cb..3d76330 100644 --- a/seismograph/case.py +++ b/seismograph/case.py @@ -387,7 +387,7 @@ def dict_equal(self, d1, d2, msg=None): """ self.__unittest__.assertDictEqual(d1, d2, msg=msg) - def dates_equal(self, date1, date2): + def _dates_format(self, date1, date2): """ To compare dates. Date can be as string and date object. @@ -400,11 +400,20 @@ def dates_equal(self, date1, date2): from_string = lambda d: sum(sorted(int(i) for i in re.findall(r'[0-9]+', d))) d1 = from_string(date1) if isinstance(date1, pyv.basestring) else from_date(date1) - d2 = from_string(date2) if isinstance(date2, basestring) else from_date(date2) + d2 = from_string(date2) if isinstance(date2, pyv.basestring) else from_date(date2) + + return d1, d2 - if d1 != d2: + def dates_equal(self, date1, date2): + dates = self._dates_format(date1, date2) + if dates[0] != dates[1]: self.fail('{} != {}'.format(date1, date2)) + def dates_not_equal(self, date1, date2): + dates = self._dates_format(date1, date2) + if dates[0] == dates[1]: + self.fail('{} = {}'.format(date1, date2)) + def response(self, resp, status,