1818
1919# this package
2020from pyproject_parser .parsers import BuildSystemParser , PEP621Parser , RequiredKeysConfigParser
21- from pyproject_parser .utils import PyProjectDeprecationWarning
21+ from pyproject_parser .utils import PyProjectDeprecationWarning , _load_toml
2222
2323
2424@pytest .mark .parametrize ("set_defaults" , [True , False ])
@@ -40,7 +40,7 @@ def test_pep621_class_valid_config(
4040
4141with in_directory (tmp_pathplus ):
4242config = PEP621Parser ().parse (
43- dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ],
43+ _load_toml (tmp_pathplus / "pyproject.toml" )["project" ],
4444set_defaults = set_defaults ,
4545)
4646
@@ -61,7 +61,7 @@ def test_pep621_subclass(
6161(tmp_pathplus / "pyproject.toml" ).write_clean (toml_config )
6262
6363with in_directory (tmp_pathplus ):
64- config = ReducedPEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
64+ config = ReducedPEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
6565
6666advanced_data_regression .check (config )
6767
@@ -82,7 +82,7 @@ def test_pep621_class_valid_config_readme(
8282(tmp_pathplus / filename ).write_text ("This is the readme." )
8383
8484with in_directory (tmp_pathplus ):
85- config = PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
85+ config = PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
8686
8787advanced_data_regression .check (config )
8888
@@ -125,7 +125,7 @@ def test_pep621_class_valid_config_readme_dict(
125125(tmp_pathplus / "README" ).write_text ("This is the README." )
126126
127127with in_directory (tmp_pathplus ):
128- config = PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
128+ config = PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
129129
130130advanced_data_regression .check (config )
131131
@@ -213,7 +213,7 @@ def test_pep621_class_bad_config_readme(
213213])
214214
215215with in_directory (tmp_pathplus ), pytest .raises (exception , match = expected ):
216- PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
216+ PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
217217
218218
219219@pytest .mark .parametrize ("filename" , ["LICENSE.rst" , "LICENSE.md" , "LICENSE.txt" , "LICENSE" ])
@@ -232,7 +232,7 @@ def test_pep621_class_valid_config_license(
232232(tmp_pathplus / filename ).write_text ("This is the license." )
233233
234234with in_directory (tmp_pathplus ):
235- config = PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
235+ config = PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
236236
237237advanced_data_regression .check (config )
238238
@@ -250,7 +250,7 @@ def test_pep621_class_valid_config_license_dict(
250250])
251251
252252with in_directory (tmp_pathplus ):
253- config = PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
253+ config = PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
254254
255255advanced_data_regression .check (config )
256256
@@ -284,7 +284,7 @@ def test_pep621_class_bad_config_license(
284284])
285285
286286with in_directory (tmp_pathplus ), pytest .raises (BadConfigError , match = expected ):
287- PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
287+ PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
288288
289289
290290@pytest .mark .parametrize (
@@ -320,7 +320,7 @@ def test_pep621_class_bad_config(
320320(tmp_pathplus / "pyproject.toml" ).write_clean (config )
321321
322322with in_directory (tmp_pathplus ), pytest .raises (expects , match = match ):
323- PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
323+ PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
324324
325325
326326@pytest .mark .parametrize (
@@ -352,7 +352,7 @@ def test_extra_deprecation(
352352(tmp_pathplus / "pyproject.toml" ).write_clean (config )
353353
354354with in_directory (tmp_pathplus ), pytest .warns (PyProjectDeprecationWarning , match = match ):
355- PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
355+ PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
356356
357357
358358@pytest .mark .parametrize ("filename" , ["README" , "README.rtf" ])
@@ -367,7 +367,7 @@ def test_parse_config_readme_errors(filename: str, tmp_pathplus: PathPlus):
367367(tmp_pathplus / filename ).write_text ("This is the readme." )
368368
369369with in_directory (tmp_pathplus ), pytest .raises (ValueError , match = f"Unsupported extension for '{ filename } '" ):
370- PEP621Parser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["project" ])
370+ PEP621Parser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["project" ])
371371
372372
373373@pytest .mark .parametrize ("set_defaults" , [True , False ])
@@ -380,7 +380,7 @@ def test_buildsystem_parser_valid_config(
380380):
381381(tmp_pathplus / "pyproject.toml" ).write_clean (toml_config )
382382config = BuildSystemParser ().parse (
383- dom_toml . load (tmp_pathplus / "pyproject.toml" )["build-system" ],
383+ _load_toml (tmp_pathplus / "pyproject.toml" )["build-system" ],
384384set_defaults = set_defaults ,
385385)
386386
@@ -394,7 +394,7 @@ def test_buildsystem_parser_errors(config: str, expects: Type[Exception], match:
394394(tmp_pathplus / "pyproject.toml" ).write_clean (config )
395395
396396with in_directory (tmp_pathplus ), pytest .raises (expects , match = match ):
397- BuildSystemParser ().parse (dom_toml . load (tmp_pathplus / "pyproject.toml" )["build-system" ])
397+ BuildSystemParser ().parse (_load_toml (tmp_pathplus / "pyproject.toml" )["build-system" ])
398398
399399
400400def test_RequiredKeysConfigParser ():
0 commit comments