@@ -186,31 +186,28 @@ def test_parse_errors(self):
186
186
with pytest .raises (CoverageException , match = msg ):
187
187
coverage .Coverage ()
188
188
189
- def test_toml_parse_errors (self ):
189
+ @pytest .mark .parametrize ("bad_config,msg" , [
190
+ ("[tool.coverage.run]\n timid = \" maybe?\" \n " , r"maybe[?]" ),
191
+ ("[tool.coverage.run\n " , None ),
192
+ ('[tool.coverage.report]\n exclude_lines = ["foo("]\n ' ,
193
+ r"Invalid \[tool.coverage.report\].exclude_lines value u?'foo\(': "
194
+ r"(unbalanced parenthesis|missing \))" ),
195
+ ('[tool.coverage.report]\n partial_branches = ["foo["]\n ' ,
196
+ r"Invalid \[tool.coverage.report\].partial_branches value u?'foo\[': "
197
+ r"(unexpected end of regular expression|unterminated character set)" ),
198
+ ('[tool.coverage.report]\n partial_branches_always = ["foo***"]\n ' ,
199
+ r"Invalid \[tool.coverage.report\].partial_branches_always value "
200
+ r"u?'foo\*\*\*': "
201
+ r"multiple repeat" ),
202
+ ('[tool.coverage.run]\n concurrency="foo"' , "not a list" ),
203
+ ("[tool.coverage.report]\n precision=1.23" , "not an integer" ),
204
+ ('[tool.coverage.report]\n fail_under="s"' , "not a float" ),
205
+ ])
206
+ def test_toml_parse_errors (self , bad_config , msg ):
190
207
# Im-parsable values raise CoverageException, with details.
191
- bad_configs_and_msgs = [
192
- ("[tool.coverage.run]\n timid = \" maybe?\" \n " , r"maybe[?]" ),
193
- ("[tool.coverage.run\n " , r"Key group" ),
194
- ('[tool.coverage.report]\n exclude_lines = ["foo("]\n ' ,
195
- r"Invalid \[tool.coverage.report\].exclude_lines value u?'foo\(': "
196
- r"(unbalanced parenthesis|missing \))" ),
197
- ('[tool.coverage.report]\n partial_branches = ["foo["]\n ' ,
198
- r"Invalid \[tool.coverage.report\].partial_branches value u?'foo\[': "
199
- r"(unexpected end of regular expression|unterminated character set)" ),
200
- ('[tool.coverage.report]\n partial_branches_always = ["foo***"]\n ' ,
201
- r"Invalid \[tool.coverage.report\].partial_branches_always value "
202
- r"u?'foo\*\*\*': "
203
- r"multiple repeat" ),
204
- ('[tool.coverage.run]\n concurrency="foo"' , "not a list" ),
205
- ("[tool.coverage.report]\n precision=1.23" , "not an integer" ),
206
- ('[tool.coverage.report]\n fail_under="s"' , "not a float" ),
207
- ]
208
-
209
- for bad_config , msg in bad_configs_and_msgs :
210
- print ("Trying %r" % bad_config )
211
- self .make_file ("pyproject.toml" , bad_config )
212
- with pytest .raises (CoverageException , match = msg ):
213
- coverage .Coverage ()
208
+ self .make_file ("pyproject.toml" , bad_config )
209
+ with pytest .raises (CoverageException , match = msg ):
210
+ coverage .Coverage ()
214
211
215
212
def test_environment_vars_in_config (self ):
216
213
# Config files can have $envvars in them.
@@ -715,15 +712,15 @@ def test_note_is_obsolete(self):
715
712
716
713
def test_no_toml_installed_no_toml (self ):
717
714
# Can't read a toml file that doesn't exist.
718
- with without_module (coverage .tomlconfig , 'toml ' ):
715
+ with without_module (coverage .tomlconfig , 'tomli ' ):
719
716
msg = "Couldn't read 'cov.toml' as a config file"
720
717
with pytest .raises (CoverageException , match = msg ):
721
718
coverage .Coverage (config_file = "cov.toml" )
722
719
723
720
def test_no_toml_installed_explicit_toml (self ):
724
721
# Can't specify a toml config file if toml isn't installed.
725
722
self .make_file ("cov.toml" , "# A toml file!" )
726
- with without_module (coverage .tomlconfig , 'toml ' ):
723
+ with without_module (coverage .tomlconfig , 'tomli ' ):
727
724
msg = "Can't read 'cov.toml' without TOML support"
728
725
with pytest .raises (CoverageException , match = msg ):
729
726
coverage .Coverage (config_file = "cov.toml" )
@@ -735,7 +732,7 @@ def test_no_toml_installed_pyproject_toml(self):
735
732
[tool.coverage.run]
736
733
xyzzy = 17
737
734
""" )
738
- with without_module (coverage .tomlconfig , 'toml ' ):
735
+ with without_module (coverage .tomlconfig , 'tomli ' ):
739
736
msg = "Can't read 'pyproject.toml' without TOML support"
740
737
with pytest .raises (CoverageException , match = msg ):
741
738
coverage .Coverage ()
@@ -747,7 +744,7 @@ def test_no_toml_installed_pyproject_no_coverage(self):
747
744
[tool.something]
748
745
xyzzy = 17
749
746
""" )
750
- with without_module (coverage .tomlconfig , 'toml ' ):
747
+ with without_module (coverage .tomlconfig , 'tomli ' ):
751
748
cov = coverage .Coverage ()
752
749
# We get default settings:
753
750
assert not cov .config .timid
0 commit comments