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 | 01e12e85608494ec51f5095f56c78dadb28a916b (patch) | |
tree | af37119a6231bad2b9ebdadbb8d715ff4d696d08 /tests/test_api.py | |
parent | f159f23dd2fbb8ff090b9310b1db6d527424c2e3 (diff) | |
download | python-coveragepy-01e12e85608494ec51f5095f56c78dadb28a916b.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 47f9004..9a3fc82 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.""" |