summaryrefslogtreecommitdiff
path: root/tests/test_config.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-11-03 18:32:01 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-11-03 21:27:42 -0500
commitdf744f8cbcad7ea7dca893be5017920afa4ce32f (patch)
tree05faf86a600898561b10ae2fed36382101a6cd9d /tests/test_config.py
parent9c04f2d6c4dd4e1bda5fae1e58c9aad846881024 (diff)
downloadpython-coveragepy-git-df744f8cbcad7ea7dca893be5017920afa4ce32f.tar.gz
Give warnings about not being able to parse TOML files if toml isn't installed
Diffstat (limited to 'tests/test_config.py')
-rw-r--r--tests/test_config.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 3bd2fd2b..74ff5f00 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -8,6 +8,7 @@ import mock
import coverage
from coverage.misc import CoverageException
+import coverage.optional
from tests.coveragetest import CoverageTest, UsingModulesMixin
@@ -651,3 +652,36 @@ class ConfigFileTest(UsingModulesMixin, CoverageTest):
self.assertFalse(cov.config.timid)
self.assertFalse(cov.config.branch)
self.assertEqual(cov.config.data_file, ".coverage")
+
+ def test_no_toml_installed_explicit_toml(self):
+ # Can't specify a toml config file if toml isn't installed.
+ with coverage.optional.without('toml'):
+ msg = "Can't read 'cov.toml' without TOML support"
+ with self.assertRaisesRegex(CoverageException, msg):
+ coverage.Coverage(config_file="cov.toml")
+
+ 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 coverage.optional.without('toml'):
+ msg = "Can't read 'pyproject.toml' without TOML support"
+ with self.assertRaisesRegex(CoverageException, 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 coverage.optional.without('toml'):
+ cov = coverage.Coverage()
+ # We get default settings:
+ self.assertFalse(cov.config.timid)
+ self.assertFalse(cov.config.branch)
+ self.assertEqual(cov.config.data_file, ".coverage")