mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-10-23 17:57:03 +02:00
Add regression tests for date parser overflow
This commit is contained in:
parent
974ac5c731
commit
9e64607012
1 changed files with 24 additions and 0 deletions
24
tests/test_recipe_overflow.py
Normal file
24
tests/test_recipe_overflow.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import pytest
|
||||
|
||||
from sqlite_utils import recipes
|
||||
|
||||
|
||||
OVERFLOWING_DATE = "999999999999999999999999999999-01-01"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("fn", ("parsedate", "parsedatetime"))
|
||||
def test_dateparse_overflow_raises_by_default(fn):
|
||||
with pytest.raises(OverflowError):
|
||||
getattr(recipes, fn)(OVERFLOWING_DATE)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("fn", ("parsedate", "parsedatetime"))
|
||||
@pytest.mark.parametrize(
|
||||
"errors,expected",
|
||||
(
|
||||
(recipes.IGNORE, OVERFLOWING_DATE),
|
||||
(recipes.SET_NULL, None),
|
||||
),
|
||||
)
|
||||
def test_dateparse_overflow_respects_errors(fn, errors, expected):
|
||||
assert getattr(recipes, fn)(OVERFLOWING_DATE, errors=errors) == expected
|
||||
Loading…
Add table
Add a link
Reference in a new issue