Skip to content

Commit

Permalink
parametrize over separator, keep date hardcoded
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Mar 4, 2019
1 parent 7dc4895 commit f61653d
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions dateutil/test/test_parser.py
Expand Up @@ -165,24 +165,20 @@ def test_parser_default(parsable_text, expected_datetime, assertion_message):
assert parse(parsable_text, default=datetime(2003, 9, 25)) == expected_datetime, assertion_message


@pytest.mark.parametrize('dstr,expected', [
("10-09-2003", datetime(2003, 9, 10)),
("10.09.2003", datetime(2003, 9, 10)),
("10/09/2003", datetime(2003, 9, 10)),
("10 09 2003", datetime(2003, 9, 10)),
])
def test_parse_dayfirst(dstr, expected):
@pytest.mark.parametrize('sep', ['-', '.', '/', ' '])
def test_parse_dayfirst(sep):
expected = datetime(2003, 9, 10)
fmt = sep.join(['%d', '%m', '%Y'])
dstr = expected.strftime(fmt)
result = parse(dstr, dayfirst=True)
assert result == expected


@pytest.mark.parametrize('dstr,expected', [
("10 09 03", datetime(2010, 9, 3)),
("10-09-03", datetime(2010, 9, 3)),
("10.09.03", datetime(2010, 9, 3)),
("10/09/03", datetime(2010, 9, 3)),
])
def test_parse_yearfirst(dstr, expected):
@pytest.mark.parametrize('sep', ['-', '.', '/', ' '])
def test_parse_yearfirst(sep):
expected = datetime(2010, 9, 3)
fmt = sep.join(['%Y', '%m', '%d'])
dstr = expected.strftime(fmt)
result = parse(dstr, yearfirst=True)
assert result == expected

Expand Down

0 comments on commit f61653d

Please sign in to comment.