@@ -65,7 +65,7 @@ def test_named_config_file(self, file_class: FilePathType) -> None:
65
65
assert cov .config .data_file == "delete.me"
66
66
67
67
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
68
- def test_toml_config_file (self , filename ) -> None :
68
+ def test_toml_config_file (self , filename : str ) -> None :
69
69
# A pyproject.toml and coveragerc.toml will be read into the configuration.
70
70
self .make_file (filename , """\
71
71
# This is just a bogus toml file for testing.
@@ -96,7 +96,7 @@ def test_toml_config_file(self, filename) -> None:
96
96
assert cov .config .get_plugin_options ("plugins.a_plugin" ) == {"hello" : "world" }
97
97
98
98
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
99
- def test_toml_ints_can_be_floats (self , filename ) -> None :
99
+ def test_toml_ints_can_be_floats (self , filename : str ) -> None :
100
100
# Test that our class doesn't reject integers when loading floats
101
101
self .make_file (filename , """\
102
102
# This is just a bogus toml file for testing.
@@ -207,7 +207,7 @@ def test_parse_errors(self, bad_config: str, msg: str) -> None:
207
207
self .make_file (".coveragerc" , bad_config )
208
208
with pytest .raises (ConfigError , match = msg ):
209
209
coverage .Coverage ()
210
-
210
+
211
211
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
212
212
@pytest .mark .parametrize ("bad_config, msg" , [
213
213
("[tool.coverage.run]\n timid = \" maybe?\" \n " , r"maybe[?]" ),
@@ -226,7 +226,7 @@ def test_parse_errors(self, bad_config: str, msg: str) -> None:
226
226
("[tool.coverage.report]\n precision=1.23" , "not an integer" ),
227
227
('[tool.coverage.report]\n fail_under="s"' , "couldn't convert to a float" ),
228
228
])
229
- def test_toml_parse_errors (self , filename , bad_config : str , msg : str ) -> None :
229
+ def test_toml_parse_errors (self , filename : str , bad_config : str , msg : str ) -> None :
230
230
# Im-parsable values raise ConfigError, with details.
231
231
self .make_file (filename , bad_config )
232
232
with pytest .raises (ConfigError , match = msg ):
@@ -255,7 +255,7 @@ def test_environment_vars_in_config(self) -> None:
255
255
assert cov .config .exclude_list == ["the_$one" , "anotherZZZ" , "xZZZy" , "xy" , "huh${X}what" ]
256
256
257
257
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
258
- def test_environment_vars_in_toml_config (self , filename ) -> None :
258
+ def test_environment_vars_in_toml_config (self , filename : str ) -> None :
259
259
# Config files can have $envvars in them.
260
260
self .make_file (filename , """\
261
261
[tool.coverage.run]
@@ -330,7 +330,7 @@ def expanduser(s: str) -> str:
330
330
assert cov .config .paths == {'mapping' : ['/Users/me/src' , '/Users/joe/source' ]}
331
331
332
332
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
333
- def test_tilde_in_toml_config (self , filename ) -> None :
333
+ def test_tilde_in_toml_config (self , filename : str ) -> None :
334
334
# Config entries that are file paths can be tilde-expanded.
335
335
self .make_file (filename , """\
336
336
[tool.coverage.run]
@@ -446,9 +446,9 @@ def test_unknown_option(self) -> None:
446
446
msg = r"Unrecognized option '\[run\] xyzzy=' in config file .coveragerc"
447
447
with pytest .warns (CoverageWarning , match = msg ):
448
448
_ = coverage .Coverage ()
449
-
449
+
450
450
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
451
- def test_unknown_option_toml (self , filename ) -> None :
451
+ def test_unknown_option_toml (self , filename : str ) -> None :
452
452
self .make_file (filename , """\
453
453
[tool.coverage.run]
454
454
xyzzy = 17
@@ -465,7 +465,7 @@ def test_unknown_option_in_other_ini_file(self) -> None:
465
465
msg = r"Unrecognized option '\[coverage:run\] huh=' in config file setup.cfg"
466
466
with pytest .warns (CoverageWarning , match = msg ):
467
467
_ = coverage .Coverage ()
468
-
468
+
469
469
def test_exceptions_from_missing_things (self ) -> None :
470
470
self .make_file ("config.ini" , """\
471
471
[run]
@@ -478,9 +478,9 @@ def test_exceptions_from_missing_things(self) -> None:
478
478
with pytest .raises (ConfigError , match = "No option 'foo' in section: 'xyzzy'" ):
479
479
config .get ("xyzzy" , "foo" )
480
480
481
-
481
+
482
482
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
483
- def test_exclude_also (self , filename ) -> None :
483
+ def test_exclude_also (self , filename : str ) -> None :
484
484
self .make_file (filename , """\
485
485
[tool.coverage.report]
486
486
exclude_also = ["foobar", "raise .*Error"]
@@ -813,9 +813,9 @@ def test_no_toml_installed_pyproject_no_coverage(self) -> None:
813
813
assert not cov .config .timid
814
814
assert not cov .config .branch
815
815
assert cov .config .data_file == ".coverage"
816
-
816
+
817
817
@pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
818
- def test_exceptions_from_missing_toml_things (self , filename ) -> None :
818
+ def test_exceptions_from_missing_toml_things (self , filename : str ) -> None :
819
819
self .make_file (filename , """\
820
820
[tool.coverage.run]
821
821
branch = true
@@ -828,7 +828,7 @@ def test_exceptions_from_missing_toml_things(self, filename) -> None:
828
828
config .get ("xyzzy" , "foo" )
829
829
with pytest .raises (ConfigError , match = "No option 'foo' in section: 'tool.coverage.run'" ):
830
830
config .get ("run" , "foo" )
831
-
831
+
832
832
def test_coveragerc_toml_priority (self ) -> None :
833
833
"""Test that .coveragerc.toml has priority over pyproject.toml."""
834
834
self .make_file (".coveragerc.toml" , """\
@@ -837,20 +837,20 @@ def test_coveragerc_toml_priority(self) -> None:
837
837
data_file = ".toml-data.dat"
838
838
branch = true
839
839
""" )
840
-
840
+
841
841
self .make_file ("pyproject.toml" , """\
842
842
[tool.coverage.run]
843
843
timid = false
844
844
data_file = "pyproject-data.dat"
845
845
branch = false
846
846
""" )
847
847
cov = coverage .Coverage ()
848
-
848
+
849
849
assert cov .config .timid is True
850
850
assert cov .config .data_file == ".toml-data.dat"
851
851
assert cov .config .branch is True
852
-
853
-
852
+
853
+
854
854
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
855
855
def test_toml_file_exists_but_no_toml_support (self ) -> None :
856
856
"""Test behavior when .coveragerc.toml exists but TOML support is missing."""
@@ -859,7 +859,7 @@ def test_toml_file_exists_but_no_toml_support(self) -> None:
859
859
timid = true
860
860
data_file = ".toml-data.dat"
861
861
""" )
862
-
862
+
863
863
with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
864
864
msg = "Can't read '.coveragerc.toml' without TOML support"
865
865
with pytest .raises (ConfigError , match = msg ):
@@ -869,7 +869,7 @@ def test_toml_file_exists_but_no_toml_support(self) -> None:
869
869
timid = false
870
870
data_file = .ini-data.dat
871
871
""" )
872
-
872
+
873
873
cov = coverage .Coverage ()
874
874
assert not cov .config .timid
875
875
assert cov .config .data_file == ".ini-data.dat"
0 commit comments