@@ -799,39 +799,35 @@ def test_no_toml_installed_explicit_toml(self) -> None:
799
799
coverage .Coverage (config_file = "cov.toml" )
800
800
801
801
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
802
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
803
- def test_no_toml_installed_pyproject_toml (self , filename ) -> None :
804
- # Can't have coverage config in pyproject.toml and .coveragerc.toml without toml installed.
805
- self .make_file (filename , """\
802
+ def test_no_toml_installed_pyproject_toml (self ) -> None :
803
+ # Can't have coverage config in pyproject.toml without toml installed.
804
+ self .make_file ("pyproject.toml" , """\
806
805
# A toml file!
807
806
[tool.coverage.run]
808
807
xyzzy = 17
809
808
""" )
810
809
with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
811
- msg = f "Can't read '{ filename } ' without TOML support"
810
+ msg = "Can't read 'pyproject.toml ' without TOML support"
812
811
with pytest .raises (ConfigError , match = msg ):
813
812
coverage .Coverage ()
814
813
815
814
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
816
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
817
- def test_no_toml_installed_pyproject_toml_shorter_syntax (self , filename ) -> None :
815
+ def test_no_toml_installed_pyproject_toml_shorter_syntax (self ) -> None :
818
816
# Can't have coverage config in pyproject.toml without toml installed.
819
- self .make_file (filename , """\
817
+ self .make_file ("pyproject.toml" , """\
820
818
# A toml file!
821
819
[tool.coverage]
822
820
run.parallel = true
823
821
""" )
824
822
with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
825
- msg = f "Can't read '{ filename } ' without TOML support"
823
+ msg = "Can't read 'pyproject.toml ' without TOML support"
826
824
with pytest .raises (ConfigError , match = msg ):
827
825
coverage .Coverage ()
828
826
829
-
830
827
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
831
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
832
- def test_no_toml_installed_pyproject_no_coverage (self , filename ) -> None :
828
+ def test_no_toml_installed_pyproject_no_coverage (self ) -> None :
833
829
# It's ok to have non-coverage pyproject.toml without toml installed.
834
- self .make_file (filename , """\
830
+ self .make_file ("pyproject.toml" , """\
835
831
# A toml file!
836
832
[tool.something]
837
833
xyzzy = 17
@@ -878,3 +874,27 @@ def test_coveragerc_toml_priority(self) -> None:
878
874
assert cov .config .timid is True
879
875
assert cov .config .data_file == ".toml-data.dat"
880
876
assert cov .config .branch is True
877
+
878
+
879
+ @pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
880
+ def test_toml_file_exists_but_no_toml_support (self ) -> None :
881
+ """Test behavior when .coveragerc.toml exists but TOML support is missing."""
882
+ self .make_file (".coveragerc.toml" , """\
883
+ [tool.coverage.run]
884
+ timid = true
885
+ data_file = ".toml-data.dat"
886
+ """ )
887
+
888
+ with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
889
+ msg = "Can't read '.coveragerc.toml' without TOML support"
890
+ with pytest .raises (ConfigError , match = msg ):
891
+ coverage .Coverage (config_file = ".coveragerc.toml" )
892
+ self .make_file (".coveragerc" , """\
893
+ [run]
894
+ timid = false
895
+ data_file = .ini-data.dat
896
+ """ )
897
+
898
+ cov = coverage .Coverage ()
899
+ assert not cov .config .timid
900
+ assert cov .config .data_file == ".ini-data.dat"
0 commit comments