def test_no_toml_installed_explicit_toml(self): # 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, 'toml'): msg = "Can't read 'cov.toml' without TOML support" with pytest.raises(CoverageException, match=msg): coverage.Coverage(config_file="cov.toml")
def test_without_module(): toml1 = tomlconfig.toml with without_module(tomlconfig, 'toml'): toml2 = tomlconfig.toml toml3 = tomlconfig.toml assert toml1 is toml3 is not None assert toml2 is None
def test_no_toml_installed_pyproject_toml(self): # Can't have coverage config in pyproject.toml without toml installed. self.make_file("pyproject.toml", """\ # A toml file! [tool.coverage.run] xyzzy = 17 """) with without_module(coverage.tomlconfig, 'toml'): msg = "Can't read 'pyproject.toml' without TOML support" with pytest.raises(CoverageException, match=msg): coverage.Coverage()
def test_no_toml_installed_pyproject_no_coverage(self): # It's ok to have non-coverage pyproject.toml without toml installed. self.make_file("pyproject.toml", """\ # A toml file! [tool.something] xyzzy = 17 """) with without_module(coverage.tomlconfig, 'toml'): cov = coverage.Coverage() # We get default settings: assert not cov.config.timid assert not cov.config.branch assert cov.config.data_file == ".coverage"
def test_no_toml_installed_no_toml(self): # Can't read a toml file that doesn't exist. with without_module(coverage.tomlconfig, 'toml'): msg = "Couldn't read 'cov.toml' as a config file" with pytest.raises(CoverageException, match=msg): coverage.Coverage(config_file="cov.toml")