Skip to content

Commit

Permalink
port sanity tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Feb 27, 2019
1 parent f52b3a7 commit 5e0e16d
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions dateutil/test/test_parser.py
Expand Up @@ -495,10 +495,6 @@ def testRandomFormat26(self):

self.assertEqual(res, datetime(1990, 6, 13, 5, 50))

def testInvalidDay(self):
with pytest.raises(ValueError):
parse("Feb 30, 2007")

def testUnspecifiedDayFallback(self):
# Test that for an unspecified day, the fallback behavior is correct.
self.assertEqual(parse("April 2009", default=datetime(2010, 1, 31)),
Expand Down Expand Up @@ -679,6 +675,41 @@ def test_era_trailing_year(self):
assert res.year == 2001, res


class TestOutOfBounds(object):

def test_no_year_zero(self):
with pytest.raises(ValueError):
parse("0000 Jun 20")

def test_out_of_bound_day(self):
with pytest.raises(ValueError):
parse("Feb 30, 2007")

@pytest.mark.parametrize('fuzzy', [True, False])
def test_day_sanity(self, fuzzy):
dstr = "2014-15-25"
with pytest.raises(ValueError):
parse(dstr, fuzzy=fuzzy)

@pytest.mark.parametrize('fuzzy', [True, False])
def test_minute_sanity(self, fuzzy):
dstr = "2014-02-28 22:64"
with pytest.raises(ValueError):
parse(dstr, fuzzy=fuzzy)

@pytest.mark.parametrize('fuzzy', [True, False])
def test_hour_sanity(self, fuzzy):
dstr = "2014-02-28 25:16 PM"
with pytest.raises(ValueError):
parse(dstr, fuzzy=fuzzy)

@pytest.mark.parametrize('fuzzy', [True, False])
def test_second_sanity(self, fuzzy):
dstr = "2014-02-28 22:14:64"
with pytest.raises(ValueError):
parse(dstr, fuzzy=fuzzy)


class TestParseUnimplementedCases(object):
@pytest.mark.xfail
def test_somewhat_ambiguous_string(self):
Expand Down

0 comments on commit 5e0e16d

Please sign in to comment.