summaryrefslogtreecommitdiff
path: root/tests/test_config.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2023-01-03 15:21:15 -0500
committerNed Batchelder <ned@nedbatchelder.com>2023-01-03 15:29:00 -0500
commit4f3ccf213d813bb57775b2643b8bae5e08cbbbd0 (patch)
treefb113cb24362ee3fd67825867874ce3aa713b55e /tests/test_config.py
parent98301ed240a141592573c2ed239e006d42a26161 (diff)
downloadpython-coveragepy-git-4f3ccf213d813bb57775b2643b8bae5e08cbbbd0.tar.gz
refactor: a better way to have maybe-importable third-party modules
Diffstat (limited to 'tests/test_config.py')
-rw-r--r--tests/test_config.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 66e71d23..08fdc113 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -15,7 +15,6 @@ from coverage.exceptions import ConfigError, CoverageWarning
from coverage.tomlconfig import TomlConfigParser
from tests.coveragetest import CoverageTest, UsingModulesMixin
-from tests.helpers import without_module
class ConfigTest(CoverageTest):
@@ -713,7 +712,7 @@ class ConfigFileTest(UsingModulesMixin, CoverageTest):
def test_no_toml_installed_no_toml(self) -> None:
# Can't read a toml file that doesn't exist.
- with without_module(coverage.tomlconfig, 'tomllib'):
+ with mock.patch.object(coverage.tomlconfig, "has_tomllib", False):
msg = "Couldn't read 'cov.toml' as a config file"
with pytest.raises(ConfigError, match=msg):
coverage.Coverage(config_file="cov.toml")
@@ -722,7 +721,7 @@ class ConfigFileTest(UsingModulesMixin, CoverageTest):
def test_no_toml_installed_explicit_toml(self) -> None:
# Can't specify a toml config file if toml isn't installed.
self.make_file("cov.toml", "# A toml file!")
- with without_module(coverage.tomlconfig, 'tomllib'):
+ with mock.patch.object(coverage.tomlconfig, "has_tomllib", False):
msg = "Can't read 'cov.toml' without TOML support"
with pytest.raises(ConfigError, match=msg):
coverage.Coverage(config_file="cov.toml")
@@ -735,7 +734,7 @@ class ConfigFileTest(UsingModulesMixin, CoverageTest):
[tool.coverage.run]
xyzzy = 17
""")
- with without_module(coverage.tomlconfig, 'tomllib'):
+ with mock.patch.object(coverage.tomlconfig, "has_tomllib", False):
msg = "Can't read 'pyproject.toml' without TOML support"
with pytest.raises(ConfigError, match=msg):
coverage.Coverage()
@@ -748,7 +747,7 @@ class ConfigFileTest(UsingModulesMixin, CoverageTest):
[tool.coverage]
run.parallel = true
""")
- with without_module(coverage.tomlconfig, 'tomllib'):
+ with mock.patch.object(coverage.tomlconfig, "has_tomllib", False):
msg = "Can't read 'pyproject.toml' without TOML support"
with pytest.raises(ConfigError, match=msg):
coverage.Coverage()
@@ -761,7 +760,7 @@ class ConfigFileTest(UsingModulesMixin, CoverageTest):
[tool.something]
xyzzy = 17
""")
- with without_module(coverage.tomlconfig, 'tomllib'):
+ with mock.patch.object(coverage.tomlconfig, "has_tomllib", False):
cov = coverage.Coverage()
# We get default settings:
assert not cov.config.timid