@@ -162,31 +162,28 @@ def test_missing_rcfile_from_environment(self):
162
162
with pytest .raises (CoverageException , match = msg ):
163
163
coverage .Coverage ()
164
164
165
- def test_parse_errors (self ):
165
+ @pytest .mark .parametrize ("bad_config, msg" , [
166
+ ("[run]\n timid = maybe?\n " , r"maybe[?]" ),
167
+ ("timid = 1\n " , r"no section headers" ),
168
+ ("[run\n " , r"\[run" ),
169
+ ("[report]\n exclude_lines = foo(\n " ,
170
+ r"Invalid \[report\].exclude_lines value 'foo\(': " +
171
+ r"(unbalanced parenthesis|missing \))" ),
172
+ ("[report]\n partial_branches = foo[\n " ,
173
+ r"Invalid \[report\].partial_branches value 'foo\[': " +
174
+ r"(unexpected end of regular expression|unterminated character set)" ),
175
+ ("[report]\n partial_branches_always = foo***\n " ,
176
+ r"Invalid \[report\].partial_branches_always value " +
177
+ r"'foo\*\*\*': " +
178
+ r"multiple repeat" ),
179
+ ])
180
+ def test_parse_errors (self , bad_config , msg ):
166
181
# Im-parsable values raise CoverageException, with details.
167
- bad_configs_and_msgs = [
168
- ("[run]\n timid = maybe?\n " , r"maybe[?]" ),
169
- ("timid = 1\n " , r"no section headers" ),
170
- ("[run\n " , r"\[run" ),
171
- ("[report]\n exclude_lines = foo(\n " ,
172
- r"Invalid \[report\].exclude_lines value 'foo\(': " +
173
- r"(unbalanced parenthesis|missing \))" ),
174
- ("[report]\n partial_branches = foo[\n " ,
175
- r"Invalid \[report\].partial_branches value 'foo\[': " +
176
- r"(unexpected end of regular expression|unterminated character set)" ),
177
- ("[report]\n partial_branches_always = foo***\n " ,
178
- r"Invalid \[report\].partial_branches_always value " +
179
- r"'foo\*\*\*': " +
180
- r"multiple repeat" ),
181
- ]
182
-
183
- for bad_config , msg in bad_configs_and_msgs :
184
- print (f"Trying { bad_config !r} " )
185
- self .make_file (".coveragerc" , bad_config )
186
- with pytest .raises (CoverageException , match = msg ):
187
- coverage .Coverage ()
182
+ self .make_file (".coveragerc" , bad_config )
183
+ with pytest .raises (CoverageException , match = msg ):
184
+ coverage .Coverage ()
188
185
189
- @pytest .mark .parametrize ("bad_config,msg" , [
186
+ @pytest .mark .parametrize ("bad_config, msg" , [
190
187
("[tool.coverage.run]\n timid = \" maybe?\" \n " , r"maybe[?]" ),
191
188
("[tool.coverage.run\n " , None ),
192
189
('[tool.coverage.report]\n exclude_lines = ["foo("]\n ' ,
@@ -681,17 +678,13 @@ def test_non_ascii(self):
681
678
assert cov .config .exclude_list == ["first" , "✘weirdo" , "third" ]
682
679
assert cov .config .html_title == "tabblo & «ταБЬℓσ» # numbers"
683
680
684
- def test_unreadable_config (self ):
681
+ @pytest .mark .parametrize ("bad_file" , ["nosuchfile.txt" , "." ])
682
+ def test_unreadable_config (self , bad_file ):
685
683
# If a config file is explicitly specified, then it is an error for it
686
684
# to not be readable.
687
- bad_files = [
688
- "nosuchfile.txt" ,
689
- "." ,
690
- ]
691
- for bad_file in bad_files :
692
- msg = f"Couldn't read { bad_file !r} as a config file"
693
- with pytest .raises (CoverageException , match = msg ):
694
- coverage .Coverage (config_file = bad_file )
685
+ msg = f"Couldn't read { bad_file !r} as a config file"
686
+ with pytest .raises (CoverageException , match = msg ):
687
+ coverage .Coverage (config_file = bad_file )
695
688
696
689
def test_nocoveragerc_file_when_specified (self ):
697
690
cov = coverage .Coverage (config_file = ".coveragerc" )
0 commit comments