@@ -67,7 +67,7 @@ def test_named_config_file(self, file_class: FilePathType) -> None:
67
67
assert cov .config .data_file == "delete.me"
68
68
69
69
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
70
- def test_toml_config_file (self , filename ) -> None :
70
+ def test_toml_config_file (self , filename : str ) -> None :
71
71
# A pyproject.toml and coveragerc.toml will be read into the configuration.
72
72
self .make_file (filename , """\
73
73
# This is just a bogus toml file for testing.
@@ -98,7 +98,7 @@ def test_toml_config_file(self, filename) -> None:
98
98
assert cov .config .get_plugin_options ("plugins.a_plugin" ) == {"hello" : "world" }
99
99
100
100
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
101
- def test_toml_ints_can_be_floats (self , filename ) -> None :
101
+ def test_toml_ints_can_be_floats (self , filename : str ) -> None :
102
102
# Test that our class doesn't reject integers when loading floats
103
103
self .make_file (filename , """\
104
104
# This is just a bogus toml file for testing.
@@ -209,7 +209,7 @@ def test_parse_errors(self, bad_config: str, msg: str) -> None:
209
209
self .make_file (".coveragerc" , bad_config )
210
210
with pytest .raises (ConfigError , match = msg ):
211
211
coverage .Coverage ()
212
-
212
+
213
213
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
214
214
@pytest .mark .parametrize ("bad_config, msg" , [
215
215
("[tool.coverage.run]\n timid = \" maybe?\" \n " , r"maybe[?]" ),
@@ -228,7 +228,7 @@ def test_parse_errors(self, bad_config: str, msg: str) -> None:
228
228
("[tool.coverage.report]\n precision=1.23" , "not an integer" ),
229
229
('[tool.coverage.report]\n fail_under="s"' , "couldn't convert to a float" ),
230
230
])
231
- def test_toml_parse_errors (self , filename , bad_config : str , msg : str ) -> None :
231
+ def test_toml_parse_errors (self , filename : str , bad_config : str , msg : str ) -> None :
232
232
# Im-parsable values raise ConfigError, with details.
233
233
self .make_file (filename , bad_config )
234
234
with pytest .raises (ConfigError , match = msg ):
@@ -257,7 +257,7 @@ def test_environment_vars_in_config(self) -> None:
257
257
assert cov .config .exclude_list == ["the_$one" , "anotherZZZ" , "xZZZy" , "xy" , "huh${X}what" ]
258
258
259
259
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
260
- def test_environment_vars_in_toml_config (self , filename ) -> None :
260
+ def test_environment_vars_in_toml_config (self , filename : str ) -> None :
261
261
# Config files can have $envvars in them.
262
262
self .make_file (filename , """\
263
263
[tool.coverage.run]
@@ -332,7 +332,7 @@ def expanduser(s: str) -> str:
332
332
assert cov .config .paths == {'mapping' : ['/Users/me/src' , '/Users/joe/source' ]}
333
333
334
334
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
335
- def test_tilde_in_toml_config (self , filename ) -> None :
335
+ def test_tilde_in_toml_config (self , filename : str ) -> None :
336
336
# Config entries that are file paths can be tilde-expanded.
337
337
self .make_file (filename , """\
338
338
[tool.coverage.run]
@@ -448,9 +448,9 @@ def test_unknown_option(self) -> None:
448
448
msg = r"Unrecognized option '\[run\] xyzzy=' in config file .coveragerc"
449
449
with pytest .warns (CoverageWarning , match = msg ):
450
450
_ = coverage .Coverage ()
451
-
451
+
452
452
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
453
- def test_unknown_option_toml (self , filename ) -> None :
453
+ def test_unknown_option_toml (self , filename : str ) -> None :
454
454
self .make_file (filename , """\
455
455
[tool.coverage.run]
456
456
xyzzy = 17
@@ -467,7 +467,7 @@ def test_unknown_option_in_other_ini_file(self) -> None:
467
467
msg = r"Unrecognized option '\[coverage:run\] huh=' in config file setup.cfg"
468
468
with pytest .warns (CoverageWarning , match = msg ):
469
469
_ = coverage .Coverage ()
470
-
470
+
471
471
def test_exceptions_from_missing_things (self ) -> None :
472
472
self .make_file ("config.ini" , """\
473
473
[run]
@@ -480,9 +480,9 @@ def test_exceptions_from_missing_things(self) -> None:
480
480
with pytest .raises (ConfigError , match = "No option 'foo' in section: 'xyzzy'" ):
481
481
config .get ("xyzzy" , "foo" )
482
482
483
-
483
+
484
484
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
485
- def test_exclude_also (self , filename ) -> None :
485
+ def test_exclude_also (self , filename : str ) -> None :
486
486
self .make_file (filename , """\
487
487
[tool.coverage.report]
488
488
exclude_also = ["foobar", "raise .*Error"]
@@ -838,9 +838,9 @@ def test_no_toml_installed_pyproject_no_coverage(self) -> None:
838
838
assert not cov .config .timid
839
839
assert not cov .config .branch
840
840
assert cov .config .data_file == ".coverage"
841
-
841
+
842
842
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
843
- def test_exceptions_from_missing_toml_things (self , filename ) -> None :
843
+ def test_exceptions_from_missing_toml_things (self , filename : str ) -> None :
844
844
self .make_file (filename , """\
845
845
[tool.coverage.run]
846
846
branch = true
@@ -853,7 +853,7 @@ def test_exceptions_from_missing_toml_things(self, filename) -> None:
853
853
config .get ("xyzzy" , "foo" )
854
854
with pytest .raises (ConfigError , match = "No option 'foo' in section: 'tool.coverage.run'" ):
855
855
config .get ("run" , "foo" )
856
-
856
+
857
857
def test_coveragerc_toml_priority (self ) -> None :
858
858
"""Test that .coveragerc.toml has priority over pyproject.toml."""
859
859
self .make_file (".coveragerc.toml" , """\
@@ -862,20 +862,20 @@ def test_coveragerc_toml_priority(self) -> None:
862
862
data_file = ".toml-data.dat"
863
863
branch = true
864
864
""" )
865
-
865
+
866
866
self .make_file ("pyproject.toml" , """\
867
867
[tool.coverage.run]
868
868
timid = false
869
869
data_file = "pyproject-data.dat"
870
870
branch = false
871
871
""" )
872
872
cov = coverage .Coverage ()
873
-
873
+
874
874
assert cov .config .timid is True
875
875
assert cov .config .data_file == ".toml-data.dat"
876
876
assert cov .config .branch is True
877
-
878
-
877
+
878
+
879
879
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
880
880
def test_toml_file_exists_but_no_toml_support (self ) -> None :
881
881
"""Test behavior when .coveragerc.toml exists but TOML support is missing."""
@@ -884,7 +884,7 @@ def test_toml_file_exists_but_no_toml_support(self) -> None:
884
884
timid = true
885
885
data_file = ".toml-data.dat"
886
886
""" )
887
-
887
+
888
888
with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
889
889
msg = "Can't read '.coveragerc.toml' without TOML support"
890
890
with pytest .raises (ConfigError , match = msg ):
@@ -894,7 +894,7 @@ def test_toml_file_exists_but_no_toml_support(self) -> None:
894
894
timid = false
895
895
data_file = .ini-data.dat
896
896
""" )
897
-
897
+
898
898
cov = coverage .Coverage ()
899
899
assert not cov .config .timid
900
900
assert cov .config .data_file == ".ini-data.dat"
0 commit comments