Skip to content

Commit

Permalink
Add test that proves datetime precision consistency (#60)
Browse files Browse the repository at this point in the history
* Add test that proves datetime precision consistency
See #22 (comment)

* Fix linting
  • Loading branch information
vrslev authored Mar 27, 2023
1 parent 614bfd0 commit d79d03f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pathlib import Path
from types import ModuleType

import pytest

import rtoml


Expand All @@ -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}

0 comments on commit d79d03f

Please sign in to comment.