Skip to content

Commit

Permalink
fix docstring for new assertion method
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Trifonov committed Dec 20, 2017
1 parent e0cd202 commit ea4e6ee
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions seismograph/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,6 @@ def dict_equal(self, d1, d2, msg=None):
self.__unittest__.assertDictEqual(d1, d2, msg=msg)

def _dates_format(self, date1, date2):
"""
To compare dates. Date can be as string and date object.
For example::
import datetime
dates_equal(datetime.date(2016, 8, 16), '16.08.2016')
"""
from_date = lambda d: sum(sorted((d.year, d.month, d.day)))
from_string = lambda d: sum(sorted(int(i) for i in re.findall(r'[0-9]+', d)))

Expand All @@ -405,11 +397,27 @@ def _dates_format(self, date1, date2):
return d1, d2

def dates_equal(self, date1, date2):
"""
To compare dates. Date can be as string and date object.
For example::
import datetime
dates_equal(datetime.date(2016, 8, 16), '16.08.2016')
"""
dates = self._dates_format(date1, date2)
if dates[0] != dates[1]:
self.fail('{} != {}'.format(date1, date2))

def dates_not_equal(self, date1, date2):
"""
To compare dates. Date can be as string and date object.
For example::
import datetime
dates_not_equal(datetime.date(2016, 8, 16), '16.08.2016')
"""
dates = self._dates_format(date1, date2)
if dates[0] == dates[1]:
self.fail('{} = {}'.format(date1, date2))
Expand Down

0 comments on commit ea4e6ee

Please sign in to comment.