Skip to content

Commit

Permalink
updated to have 1-6 microseconds (uiri#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
markman123 committed Oct 15, 2020
1 parent 9be6458 commit cb2a9ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def test_bug_196():
assert round_trip_bug_dict == bug_dict
assert round_trip_bug_dict['x'] == bug_dict['x']

def test_bug_314():
data = """12:34:56.1 1
12:34:56.12 12
12:34:56.123 123
12:34:56.1234 1234
12:34:56.12345 12345
12:34:56.123456 123456
12:34:56.1234567 123456"""
for line in data.splitlines():
input_, expected = tuple(line.split(" "))
decoded = toml.loads(f"a={input_}")['a']
assert decoded.microsecond == int(expected)

def test_valid_tests():
valid_dir = "toml-test/tests/valid/"
Expand Down
2 changes: 1 addition & 1 deletion toml/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _getpath(p):
FNFError = IOError


TIME_RE = re.compile(r"([0-9]{2}):([0-9]{2}):([0-9]{2})(\.([0-9]{3,6}))?")
TIME_RE = re.compile(r"([0-9]{2}):([0-9]{2}):([0-9]{2})(\.([0-9]{1,6}))?")


class TomlDecodeError(ValueError):
Expand Down

0 comments on commit cb2a9ce

Please sign in to comment.