예제 #1
0
 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")
예제 #2
0
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
예제 #3
0
 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()
예제 #4
0
 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"
예제 #5
0
 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")