test_parser_prop.py 550 B

12345678910111213141516171819202122
  1. from hypothesis.strategies import integers
  2. from hypothesis import given
  3. import pytest
  4. from dateutil.parser import parserinfo
  5. @pytest.mark.parserinfo
  6. @given(integers(min_value=100, max_value=9999))
  7. def test_convertyear(n):
  8. assert n == parserinfo().convertyear(n)
  9. @pytest.mark.parserinfo
  10. @given(integers(min_value=-50,
  11. max_value=49))
  12. def test_convertyear_no_specified_century(n):
  13. p = parserinfo()
  14. new_year = p._year + n
  15. result = p.convertyear(new_year % 100, century_specified=False)
  16. assert result == new_year