Skip to content

Commit

Permalink
iterate over all files in toml-test/tests/{valid,invalid}, including …
Browse files Browse the repository at this point in the history
…sub dirs (#427)
  • Loading branch information
hliang authored Oct 10, 2023
1 parent 2a8e94e commit ce4f7a4
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ def test_bug_196():

def test_valid_tests():
valid_dir = "toml-test/tests/valid/"
for f in os.listdir(valid_dir):
if not f.endswith("toml"):
continue
with open(os.path.join(valid_dir, f)) as fh:
toml.dumps(toml.load(fh))
for path, sub_dirs, files in os.walk(valid_dir):
for name in files:
f = os.path.join(path, name)
if not f.endswith("toml"):
continue
with open(f) as fh:
toml.dumps(toml.load(fh))


def test_circular_ref():
Expand Down Expand Up @@ -168,12 +170,14 @@ def test_decimal():

def test_invalid_tests():
invalid_dir = "toml-test/tests/invalid/"
for f in os.listdir(invalid_dir):
if not f.endswith("toml"):
continue
with pytest.raises(toml.TomlDecodeError):
with open(os.path.join(invalid_dir, f)) as fh:
toml.load(fh)
for path, sub_dirs, files in os.walk(invalid_dir):
for name in files:
f = os.path.join(path, name)
if not f.endswith("toml"):
continue
with pytest.raises(toml.TomlDecodeError):
with open(f) as fh:
toml.load(fh)


def test_exceptions():
Expand Down

0 comments on commit ce4f7a4

Please sign in to comment.