15
15
from coverage .tomlconfig import TomlConfigParser
16
16
17
17
from tests .coveragetest import CoverageTest , UsingModulesMixin
18
- from tests .helpers import without_module
19
18
20
19
21
20
class ConfigTest (CoverageTest ):
@@ -713,7 +712,7 @@ def test_nocoveragerc_file_when_specified(self) -> None:
713
712
714
713
def test_no_toml_installed_no_toml (self ) -> None :
715
714
# 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 ):
717
716
msg = "Couldn't read 'cov.toml' as a config file"
718
717
with pytest .raises (ConfigError , match = msg ):
719
718
coverage .Coverage (config_file = "cov.toml" )
@@ -722,7 +721,7 @@ def test_no_toml_installed_no_toml(self) -> None:
722
721
def test_no_toml_installed_explicit_toml (self ) -> None :
723
722
# Can't specify a toml config file if toml isn't installed.
724
723
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 ):
726
725
msg = "Can't read 'cov.toml' without TOML support"
727
726
with pytest .raises (ConfigError , match = msg ):
728
727
coverage .Coverage (config_file = "cov.toml" )
@@ -735,7 +734,7 @@ def test_no_toml_installed_pyproject_toml(self) -> None:
735
734
[tool.coverage.run]
736
735
xyzzy = 17
737
736
""" )
738
- with without_module (coverage .tomlconfig , 'tomllib' ):
737
+ with mock . patch . object (coverage .tomlconfig , "has_tomllib" , False ):
739
738
msg = "Can't read 'pyproject.toml' without TOML support"
740
739
with pytest .raises (ConfigError , match = msg ):
741
740
coverage .Coverage ()
@@ -748,7 +747,7 @@ def test_no_toml_installed_pyproject_toml_shorter_syntax(self) -> None:
748
747
[tool.coverage]
749
748
run.parallel = true
750
749
""" )
751
- with without_module (coverage .tomlconfig , 'tomllib' ):
750
+ with mock . patch . object (coverage .tomlconfig , "has_tomllib" , False ):
752
751
msg = "Can't read 'pyproject.toml' without TOML support"
753
752
with pytest .raises (ConfigError , match = msg ):
754
753
coverage .Coverage ()
@@ -761,7 +760,7 @@ def test_no_toml_installed_pyproject_no_coverage(self) -> None:
761
760
[tool.something]
762
761
xyzzy = 17
763
762
""" )
764
- with without_module (coverage .tomlconfig , 'tomllib' ):
763
+ with mock . patch . object (coverage .tomlconfig , "has_tomllib" , False ):
765
764
cov = coverage .Coverage ()
766
765
# We get default settings:
767
766
assert not cov .config .timid
0 commit comments