1515from coverage .tomlconfig import TomlConfigParser
1616
1717from tests .coveragetest import CoverageTest , UsingModulesMixin
18- from tests .helpers import without_module
1918
2019
2120class ConfigTest (CoverageTest ):
@@ -713,7 +712,7 @@ def test_nocoveragerc_file_when_specified(self) -> None:
713712
714713 def test_no_toml_installed_no_toml (self ) -> None :
715714 # Can't read a toml file that doesn't exist.
716- with without_module (coverage .tomlconfig , 'tomllib' ):
715+ with mock . patch . object (coverage .tomlconfig , "has_tomllib" , False ):
717716 msg = "Couldn't read 'cov.toml' as a config file"
718717 with pytest .raises (ConfigError , match = msg ):
719718 coverage .Coverage (config_file = "cov.toml" )
@@ -722,7 +721,7 @@ def test_no_toml_installed_no_toml(self) -> None:
722721 def test_no_toml_installed_explicit_toml (self ) -> None :
723722 # Can't specify a toml config file if toml isn't installed.
724723 self .make_file ("cov.toml" , "# A toml file!" )
725- with without_module (coverage .tomlconfig , 'tomllib' ):
724+ with mock . patch . object (coverage .tomlconfig , "has_tomllib" , False ):
726725 msg = "Can't read 'cov.toml' without TOML support"
727726 with pytest .raises (ConfigError , match = msg ):
728727 coverage .Coverage (config_file = "cov.toml" )
@@ -735,7 +734,7 @@ def test_no_toml_installed_pyproject_toml(self) -> None:
735734 [tool.coverage.run]
736735 xyzzy = 17
737736 """ )
738- with without_module (coverage .tomlconfig , 'tomllib' ):
737+ with mock . patch . object (coverage .tomlconfig , "has_tomllib" , False ):
739738 msg = "Can't read 'pyproject.toml' without TOML support"
740739 with pytest .raises (ConfigError , match = msg ):
741740 coverage .Coverage ()
@@ -748,7 +747,7 @@ def test_no_toml_installed_pyproject_toml_shorter_syntax(self) -> None:
748747 [tool.coverage]
749748 run.parallel = true
750749 """ )
751- with without_module (coverage .tomlconfig , 'tomllib' ):
750+ with mock . patch . object (coverage .tomlconfig , "has_tomllib" , False ):
752751 msg = "Can't read 'pyproject.toml' without TOML support"
753752 with pytest .raises (ConfigError , match = msg ):
754753 coverage .Coverage ()
@@ -761,7 +760,7 @@ def test_no_toml_installed_pyproject_no_coverage(self) -> None:
761760 [tool.something]
762761 xyzzy = 17
763762 """ )
764- with without_module (coverage .tomlconfig , 'tomllib' ):
763+ with mock . patch . object (coverage .tomlconfig , "has_tomllib" , False ):
765764 cov = coverage .Coverage ()
766765 # We get default settings:
767766 assert not cov .config .timid
0 commit comments