@@ -859,38 +859,35 @@ def test_no_toml_installed_explicit_toml(self) -> None:
859
859
coverage .Coverage (config_file = "cov.toml" )
860
860
861
861
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
862
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
863
- def test_no_toml_installed_pyproject_toml (self , filename ) -> None :
864
- # Can't have coverage config in pyproject.toml and .coveragerc.toml without toml installed.
865
- self .make_file (filename , """\
862
+ def test_no_toml_installed_pyproject_toml (self ) -> None :
863
+ # Can't have coverage config in pyproject.toml without toml installed.
864
+ self .make_file ("pyproject.toml" , """\
866
865
# A toml file!
867
866
[tool.coverage.run]
868
867
xyzzy = 17
869
868
""" )
870
869
with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
871
- msg = f "Can't read '{ filename } ' without TOML support"
870
+ msg = "Can't read 'pyproject.toml ' without TOML support"
872
871
with pytest .raises (ConfigError , match = msg ):
873
872
coverage .Coverage ()
874
873
875
874
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
876
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
877
- def test_no_toml_installed_pyproject_toml_shorter_syntax (self , filename ) -> None :
875
+ def test_no_toml_installed_pyproject_toml_shorter_syntax (self ) -> None :
878
876
# Can't have coverage config in pyproject.toml without toml installed.
879
- self .make_file (filename , """\
877
+ self .make_file ("pyproject.toml" , """\
880
878
# A toml file!
881
879
[tool.coverage]
882
880
run.parallel = true
883
881
""" )
884
882
with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
885
- msg = f "Can't read '{ filename } ' without TOML support"
883
+ msg = "Can't read 'pyproject.toml ' without TOML support"
886
884
with pytest .raises (ConfigError , match = msg ):
887
885
coverage .Coverage ()
888
886
889
887
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
890
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
891
- def test_no_toml_installed_pyproject_no_coverage (self , filename ) -> None :
888
+ def test_no_toml_installed_pyproject_no_coverage (self ) -> None :
892
889
# It's ok to have non-coverage pyproject.toml without toml installed.
893
- self .make_file (filename , """\
890
+ self .make_file ("pyproject.toml" , """\
894
891
# A toml file!
895
892
[tool.something]
896
893
xyzzy = 17
@@ -937,3 +934,27 @@ def test_coveragerc_toml_priority(self) -> None:
937
934
assert cov .config .timid is True
938
935
assert cov .config .data_file == ".toml-data.dat"
939
936
assert cov .config .branch is True
937
+
938
+
939
+ @pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
940
+ def test_toml_file_exists_but_no_toml_support (self ) -> None :
941
+ """Test behavior when .coveragerc.toml exists but TOML support is missing."""
942
+ self .make_file (".coveragerc.toml" , """\
943
+ [tool.coverage.run]
944
+ timid = true
945
+ data_file = ".toml-data.dat"
946
+ """ )
947
+
948
+ with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
949
+ msg = "Can't read '.coveragerc.toml' without TOML support"
950
+ with pytest .raises (ConfigError , match = msg ):
951
+ coverage .Coverage (config_file = ".coveragerc.toml" )
952
+ self .make_file (".coveragerc" , """\
953
+ [run]
954
+ timid = false
955
+ data_file = .ini-data.dat
956
+ """ )
957
+
958
+ cov = coverage .Coverage ()
959
+ assert not cov .config .timid
960
+ assert cov .config .data_file == ".ini-data.dat"
0 commit comments