summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <nedbat@gmail.com>2016-12-18 21:31:51 -0500
committerNed Batchelder <nedbat@gmail.com>2016-12-18 21:31:51 -0500
commit18649f5d03c962211c3a157896aee5053992594a (patch)
tree53142676fc60c9fdf9e894134afd525cbd5ebcb0 /tests
parentff3b97a0b4f7ca264f7b7897cc101521485cdff8 (diff)
parent4b6a63868785034da48dad3ce246eaf4fb999a56 (diff)
downloadpython-coveragepy-18649f5d03c962211c3a157896aee5053992594a.tar.gz
Merged in dachary/coverage.py/issue-493-2 (pull request #108)
finally happens before return in a try #493
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmdline.py6
-rw-r--r--tests/test_config.py2
-rw-r--r--tests/test_execfile.py19
-rw-r--r--tests/test_process.py3
4 files changed, 27 insertions, 3 deletions
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py
index 3b982eb..3b674de 100644
--- a/tests/test_cmdline.py
+++ b/tests/test_cmdline.py
@@ -16,7 +16,7 @@ import coverage.cmdline
from coverage import env
from coverage.config import CoverageConfig
from coverage.data import CoverageData, CoverageDataFiles
-from coverage.misc import ExceptionDuringRun
+from coverage.misc import CoverageException, ExceptionDuringRun
from tests.coveragetest import CoverageTest, OK, ERR
@@ -459,6 +459,10 @@ class CmdLineTest(BaseCmdLineTest):
.save()
""")
+ def test_bad_run_args_with_both_source_and_include(self):
+ with self.assertRaisesRegex(CoverageException, 'mutually exclusive'):
+ self.command_line("run --include=pre1,pre2 --source=lol,wut foo.py", ret=ERR)
+
def test_bad_concurrency(self):
self.command_line("run --concurrency=nothing", ret=ERR)
out = self.stdout()
diff --git a/tests/test_config.py b/tests/test_config.py
index 6cb5e46..2aa592b 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -239,7 +239,6 @@ class ConfigFileTest(CoverageTest):
branch = 1
cover_pylib = TRUE
parallel = on
- include = a/ , b/
concurrency = thread
source = myapp
plugins =
@@ -329,7 +328,6 @@ class ConfigFileTest(CoverageTest):
self.assertEqual(cov.get_exclude_list(), ["if 0:", r"pragma:?\s+no cover", "another_tab"])
self.assertTrue(cov.config.ignore_errors)
- self.assertEqual(cov.config.include, ["a/", "b/"])
self.assertEqual(cov.config.omit, ["one", "another", "some_more", "yet_more"])
self.assertEqual(cov.config.precision, 3)
diff --git a/tests/test_execfile.py b/tests/test_execfile.py
index 889d6cf..8585b16 100644
--- a/tests/test_execfile.py
+++ b/tests/test_execfile.py
@@ -145,6 +145,25 @@ class RunPycFileTest(CoverageTest):
with self.assertRaisesRegex(NoCode, "No file to run: 'xyzzy.pyc'"):
run_python_file("xyzzy.pyc", [])
+ def test_running_py_from_binary(self):
+ # Use make_file to get the bookkeeping. Ideally, it would
+ # be able to write binary files.
+ bf = self.make_file("binary")
+ with open(bf, "wb") as f:
+ f.write(b'\x7fELF\x02\x01\x01\x00\x00\x00')
+
+ msg = (
+ r"Couldn't run 'binary' as Python code: "
+ r"(TypeError|ValueError): "
+ r"("
+ r"compile\(\) expected string without null bytes" # for py2
+ r"|"
+ r"source code string cannot contain null bytes" # for py3
+ r")"
+ )
+ with self.assertRaisesRegex(Exception, msg):
+ run_python_file(bf, [bf])
+
class RunModuleTest(CoverageTest):
"""Test run_python_module."""
diff --git a/tests/test_process.py b/tests/test_process.py
index 81cd5ad..57639db 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -11,6 +11,8 @@ import re
import sys
import textwrap
+import pytest
+
import coverage
from coverage import env, CoverageData
from coverage.misc import output_encoding
@@ -692,6 +694,7 @@ class ProcessTest(CoverageTest):
self.assertEqual(len(infos), 1)
self.assertEqual(infos[0]['note'], u"These are musical notes: ♫𝅗𝅥♩")
+ @pytest.mark.expensive
def test_fullcoverage(self): # pragma: not covered
if env.PY2: # This doesn't work on Python 2.
self.skipTest("fullcoverage doesn't work on Python 2.")