diff options
| author | Paul Ganssle <paul@ganssle.io> | 2019-04-23 09:02:49 -0400 |
|---|---|---|
| committer | Paul Ganssle <paul@ganssle.io> | 2019-04-23 10:50:24 -0400 |
| commit | f764c8a91b8ed2eeeecbd0b6db4c0a33a350e22f (patch) | |
| tree | 0ec512145f654432755d6f3b9334e6f1adb55ca3 /dateutil | |
| parent | 31e8c66d76b1a53ab692decf4330b6b5706bf08c (diff) | |
| download | dateutil-git-f764c8a91b8ed2eeeecbd0b6db4c0a33a350e22f.tar.gz | |
Convert all parser raises tests to use ParserError
ParserError is a subclass of ValueError, so this just makes the tests
stricter, and this can be considered a backwards-compatible change.
Diffstat (limited to 'dateutil')
| -rw-r--r-- | dateutil/test/test_parser.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/dateutil/test/test_parser.py b/dateutil/test/test_parser.py index 8c08c68..25d585a 100644 --- a/dateutil/test/test_parser.py +++ b/dateutil/test/test_parser.py @@ -292,7 +292,7 @@ class TestFormat(object): class TestInputTypes(object): def test_empty_string_invalid(self): - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse('') def test_none_invalid(self): @@ -479,17 +479,17 @@ class ParserTest(unittest.TestCase): tzinfo=tzoffset(None, 10800))) def testAMPMNoHour(self): - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse("AM") - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse("Jan 20, 2015 PM") def testAMPMRange(self): - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse("13:44 AM") - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse("January 25, 1921 23:13 PM") def testPertain(self): @@ -565,15 +565,15 @@ class ParserTest(unittest.TestCase): datetime(2008, 2, 29)) def testErrorType01(self): - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse('shouldfail') def testCorrectErrorOnFuzzyWithTokens(self): - assertRaisesRegex(self, ValueError, 'Unknown string format', + assertRaisesRegex(self, ParserError, 'Unknown string format', parse, '04/04/32/423', fuzzy_with_tokens=True) - assertRaisesRegex(self, ValueError, 'Unknown string format', + assertRaisesRegex(self, ParserError, 'Unknown string format', parse, '04/04/04 +32423', fuzzy_with_tokens=True) - assertRaisesRegex(self, ValueError, 'Unknown string format', + assertRaisesRegex(self, ParserError, 'Unknown string format', parse, '04/04/0d4', fuzzy_with_tokens=True) def testIncreasingCTime(self): @@ -714,7 +714,7 @@ class ParserTest(unittest.TestCase): def test_validate_hour(self): # See GH353 invalid = "201A-01-01T23:58:39.239769+03:00" - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse(invalid) def test_era_trailing_year(self): @@ -736,31 +736,31 @@ class ParserTest(unittest.TestCase): class TestOutOfBounds(object): def test_no_year_zero(self): - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse("0000 Jun 20") def test_out_of_bound_day(self): - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse("Feb 30, 2007") def test_day_sanity(self, fuzzy): dstr = "2014-15-25" - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse(dstr, fuzzy=fuzzy) def test_minute_sanity(self, fuzzy): dstr = "2014-02-28 22:64" - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse(dstr, fuzzy=fuzzy) def test_hour_sanity(self, fuzzy): dstr = "2014-02-28 25:16 PM" - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse(dstr, fuzzy=fuzzy) def test_second_sanity(self, fuzzy): dstr = "2014-02-28 22:14:64" - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse(dstr, fuzzy=fuzzy) @@ -813,7 +813,7 @@ class TestParseUnimplementedCases(object): @pytest.mark.xfail def test_non_date_number(self): dstr = '1,700' - with pytest.raises(ValueError): + with pytest.raises(ParserError): parse(dstr) @pytest.mark.xfail @@ -935,7 +935,7 @@ def test_rounding_floatlike_strings(dtstr, dt): @pytest.mark.parametrize('value', ['1: test', 'Nan']) def test_decimal_error(value): - # GH 632, GH 662 - decimal.Decimal raises some non-ValueError exception when - # constructed with an invalid value - with pytest.raises(ValueError): + # GH 632, GH 662 - decimal.Decimal raises some non-ParserError exception + # when constructed with an invalid value + with pytest.raises(ParserError): parse(value) |
