88
99from . import burntsushi , tomllib
1010
11-
12- class MissingFile :
13- def __init__ (self , path : Path ):
14- self .path = path
15-
16-
1711DATA_DIR = Path (__file__ ).parent / "data"
1812
1913VALID_FILES = tuple ((DATA_DIR / "valid" ).glob ("**/*.toml" ))
@@ -22,10 +16,7 @@ def __init__(self, path: Path):
2216_expected_files = []
2317for p in VALID_FILES :
2418 json_path = p .with_suffix (".json" )
25- try :
26- text = json .loads (json_path .read_bytes ().decode ())
27- except FileNotFoundError :
28- text = MissingFile (json_path )
19+ text = json .loads (json_path .read_bytes ().decode ())
2920 _expected_files .append (text )
3021VALID_FILES_EXPECTED = tuple (_expected_files )
3122
@@ -49,15 +40,25 @@ def test_invalid(self):
4940 def test_valid (self ):
5041 for valid , expected in zip (VALID_FILES , VALID_FILES_EXPECTED ):
5142 with self .subTest (msg = valid .stem ):
52- if isinstance (expected , MissingFile ):
53- # For a poor man's xfail, assert that this is one of the
54- # test cases where expected data is known to be missing.
55- assert valid .stem in {
56- "qa-array-inline-nested-1000" ,
57- "qa-table-inline-nested-1000" ,
58- }
59- continue
6043 toml_str = valid .read_bytes ().decode ()
44+
45+ # xfail on TOML 1.1 compatibility tests that Tomli isn't
46+ # compatible with yet.
47+ if valid .stem in {
48+ "no-seconds" ,
49+ "newline" ,
50+ "newline-comment" ,
51+ "hex-escape" ,
52+ "common-47" ,
53+ "common-34" ,
54+ "common-31" ,
55+ "common-29" ,
56+ "common-12" ,
57+ }:
58+ with self .assertRaises (tomllib .TOMLDecodeError ):
59+ tomllib .loads (toml_str )
60+ continue
61+
6162 actual = tomllib .loads (toml_str )
6263 actual = burntsushi .convert (actual ) # type: ignore[no-untyped-call]
6364 expected = burntsushi .normalize (expected )
0 commit comments