Skip to content

Commit

Permalink
Merge pull request #699 from eamanu/fix-688
Browse files Browse the repository at this point in the history
Add a assertWarns to avoid unnecessary messages.
  • Loading branch information
noviluni committed Jun 10, 2020
2 parents 53a1933 + 0793113 commit 193148c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ def test_should_use_correct_day_from_settings_for_dates_without_day(
param(date_string='25-03-14', date_formats='%d-%m-%y', expected_result=datetime(2014, 3, 25)),
])
def test_should_support_a_string_as_date_formats(self, date_string, date_formats, expected_result):
self.when_date_is_parsed_with_formats(date_string, date_formats)
if six.PY2:
self.when_date_is_parsed_with_formats(date_string, date_formats)
else:
self.when_date_is_parsed_with_formats_and_raise_warn(date_string, date_formats)
self.then_date_was_parsed()
self.then_parsed_period_is('day')
self.then_parsed_date_is(expected_result)
Expand All @@ -319,6 +322,11 @@ def given_now(self, year, month, day, **time):
def when_date_is_parsed_with_formats(self, date_string, date_formats, custom_settings=None):
self.result = date.parse_with_formats(date_string, date_formats, custom_settings or settings)

def when_date_is_parsed_with_formats_and_raise_warn(self, date_string, date_formats, custom_settings=None):
# Just available for Python 3
with self.assertWarns(FutureWarning):
self.result = date.parse_with_formats(date_string, date_formats, custom_settings or settings)

def then_date_was_not_parsed(self):
self.assertIsNotNone(self.result)
self.assertIsNone(self.result['date_obj'])
Expand Down

0 comments on commit 193148c

Please sign in to comment.