diff --git a/tests/test_misc.py b/tests/test_misc.py index 10539aa..a65fa43 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2,6 +2,8 @@ from pathlib import Path from types import ModuleType +import pytest + import rtoml @@ -17,3 +19,17 @@ def test_example(): def test_version(): assert isinstance(rtoml.__version__, str) print('rtoml __version__:', rtoml.__version__) + + +@pytest.mark.parametrize( + 'dt', + [ + # passes, for 6 significant subsecond digits + '2020-05-25T12:00:01.123456', + # previously failed because last subsecond digit is not dumped to string + # and load parsing fails with only 5 fractional digits + '2020-05-25T12:00:01.123450', + ], +) +def test_datetime_precision(dt): + assert rtoml.loads(rtoml.dumps({'a': dt})) == {'a': dt}