diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2017-04-06 18:29:51 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2017-04-06 18:29:51 -0400 |
commit | dce26d45a70e45972ac44b7aa23a68f9bb3ae749 (patch) | |
tree | fdd0a6b31e016581058775cf906934548b27a0d0 /tests/test_api.py | |
parent | 4cc46354b3cf03f553ea69dd47611b9cc0498621 (diff) | |
download | python-coveragepy-git-dce26d45a70e45972ac44b7aa23a68f9bb3ae749.tar.gz |
Convert two warnings tests to non-process
Diffstat (limited to 'tests/test_api.py')
-rw-r--r-- | tests/test_api.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_api.py b/tests/test_api.py index 47f90045..9a3fc820 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -401,6 +401,49 @@ class ApiTest(CoverageTest): self.assertEqual(statements, [1, 2]) self.assertEqual(missing, [1, 2]) + def test_warnings(self): + self.make_file("hello.py", """\ + import sys, os + print("Hello") + """) + cov = coverage.Coverage(source=["sys", "xyzzy", "quux"]) + self.start_import_stop(cov, "hello") + cov.get_data() + + out = self.stdout() + self.assertIn("Hello\n", out) + + err = self.stderr() + self.assertIn(textwrap.dedent("""\ + Coverage.py warning: Module sys has no Python source. (module-not-python) + Coverage.py warning: Module xyzzy was never imported. (module-not-imported) + Coverage.py warning: Module quux was never imported. (module-not-imported) + Coverage.py warning: No data was collected. (no-data-collected) + """), err) + + def test_warnings_suppressed(self): + self.make_file("hello.py", """\ + import sys, os + print("Hello") + """) + self.make_file(".coveragerc", """\ + [run] + disable_warnings = no-data-collected, module-not-imported + """) + cov = coverage.Coverage(source=["sys", "xyzzy", "quux"]) + self.start_import_stop(cov, "hello") + cov.get_data() + + out = self.stdout() + self.assertIn("Hello\n", out) + + err = self.stderr() + self.assertIn(textwrap.dedent("""\ + Coverage.py warning: Module sys has no Python source. (module-not-python) + """), err) + self.assertNotIn("module-not-imported", err) + self.assertNotIn("no-data-collected", err) + class NamespaceModuleTest(CoverageTest): """Test PEP-420 namespace modules.""" |