@@ -774,39 +774,35 @@ def test_no_toml_installed_explicit_toml(self) -> None:
774
774
coverage .Coverage (config_file = "cov.toml" )
775
775
776
776
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
777
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
778
- def test_no_toml_installed_pyproject_toml (self , filename ) -> None :
779
- # Can't have coverage config in pyproject.toml and .coveragerc.toml without toml installed.
780
- self .make_file (filename , """\
777
+ def test_no_toml_installed_pyproject_toml (self ) -> None :
778
+ # Can't have coverage config in pyproject.toml without toml installed.
779
+ self .make_file ("pyproject.toml" , """\
781
780
# A toml file!
782
781
[tool.coverage.run]
783
782
xyzzy = 17
784
783
""" )
785
784
with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
786
- msg = f "Can't read '{ filename } ' without TOML support"
785
+ msg = "Can't read 'pyproject.toml ' without TOML support"
787
786
with pytest .raises (ConfigError , match = msg ):
788
787
coverage .Coverage ()
789
788
790
789
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
791
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
792
- def test_no_toml_installed_pyproject_toml_shorter_syntax (self , filename ) -> None :
790
+ def test_no_toml_installed_pyproject_toml_shorter_syntax (self ) -> None :
793
791
# Can't have coverage config in pyproject.toml without toml installed.
794
- self .make_file (filename , """\
792
+ self .make_file ("pyproject.toml" , """\
795
793
# A toml file!
796
794
[tool.coverage]
797
795
run.parallel = true
798
796
""" )
799
797
with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
800
- msg = f "Can't read '{ filename } ' without TOML support"
798
+ msg = "Can't read 'pyproject.toml ' without TOML support"
801
799
with pytest .raises (ConfigError , match = msg ):
802
800
coverage .Coverage ()
803
801
804
-
805
802
@pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
806
- @pytest .mark .parametrize ("filename" , ["pyproject.toml" , ".coveragerc.toml" ])
807
- def test_no_toml_installed_pyproject_no_coverage (self , filename ) -> None :
803
+ def test_no_toml_installed_pyproject_no_coverage (self ) -> None :
808
804
# It's ok to have non-coverage pyproject.toml without toml installed.
809
- self .make_file (filename , """\
805
+ self .make_file ("pyproject.toml" , """\
810
806
# A toml file!
811
807
[tool.something]
812
808
xyzzy = 17
@@ -853,3 +849,27 @@ def test_coveragerc_toml_priority(self) -> None:
853
849
assert cov .config .timid is True
854
850
assert cov .config .data_file == ".toml-data.dat"
855
851
assert cov .config .branch is True
852
+
853
+
854
+ @pytest .mark .skipif (env .PYVERSION >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
855
+ def test_toml_file_exists_but_no_toml_support (self ) -> None :
856
+ """Test behavior when .coveragerc.toml exists but TOML support is missing."""
857
+ self .make_file (".coveragerc.toml" , """\
858
+ [tool.coverage.run]
859
+ timid = true
860
+ data_file = ".toml-data.dat"
861
+ """ )
862
+
863
+ with mock .patch .object (coverage .tomlconfig , "has_tomllib" , False ):
864
+ msg = "Can't read '.coveragerc.toml' without TOML support"
865
+ with pytest .raises (ConfigError , match = msg ):
866
+ coverage .Coverage (config_file = ".coveragerc.toml" )
867
+ self .make_file (".coveragerc" , """\
868
+ [run]
869
+ timid = false
870
+ data_file = .ini-data.dat
871
+ """ )
872
+
873
+ cov = coverage .Coverage ()
874
+ assert not cov .config .timid
875
+ assert cov .config .data_file == ".ini-data.dat"
0 commit comments