summaryrefslogtreecommitdiff
path: root/test/test_cmdline.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-01-03 10:23:06 -0500
committerNed Batchelder <ned@nedbatchelder.com>2010-01-03 10:23:06 -0500
commit2fd7773780de939169ca4ae8ad347f92785cd112 (patch)
tree24391041799b3d7e55b5cb1a60edfc9ee6cf9f08 /test/test_cmdline.py
parentf34cffd56572c46015615d4e541c600fde6c5af4 (diff)
downloadpython-coveragepy-git-2fd7773780de939169ca4ae8ad347f92785cd112.tar.gz
Parallel mode can be set from the .coveragerc file.
Diffstat (limited to 'test/test_cmdline.py')
-rw-r--r--test/test_cmdline.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/test/test_cmdline.py b/test/test_cmdline.py
index fda282bb..9196873f 100644
--- a/test/test_cmdline.py
+++ b/test/test_cmdline.py
@@ -1,6 +1,6 @@
"""Test cmdline.py for coverage."""
-import os, re, shlex, sys, textwrap, unittest
+import os, pprint, re, shlex, sys, textwrap, unittest
import mock
import coverage
@@ -14,7 +14,7 @@ class CmdLineTest(CoverageTest):
run_in_temp_dir = False
INIT_LOAD = """\
- .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None, config_file=True)
+ .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True)
.load()\n"""
def model_object(self):
@@ -47,14 +47,24 @@ class CmdLineTest(CoverageTest):
m2 = self.model_object()
code_obj = compile(code, "<code>", "exec")
eval(code_obj, globals(), { 'm2': m2 })
- self.assertEqual(m1.method_calls, m2.method_calls)
+ self.assert_same_method_calls(m1, m2)
def cmd_executes_same(self, args1, args2):
"""Assert that the `args1` executes the same as `args2`."""
m1, r1 = self.mock_command_line(args1)
m2, r2 = self.mock_command_line(args2)
self.assertEqual(r1, r2)
- self.assertEqual(m1.method_calls, m2.method_calls)
+ self.assert_same_method_calls(m1, m2)
+
+ def assert_same_method_calls(self, m1, m2):
+ """Assert that `m1.method_calls` and `m2.method_calls` are the same."""
+ # Use a real equality comparison, but if it fails, use a nicer assert
+ # so we can tell what's going on. We have to use the real == first due
+ # to CmdOptionParser.__eq__
+ if m1.method_calls != m2.method_calls:
+ pp1 = pprint.pformat(m1.method_calls)
+ pp2 = pprint.pformat(m2.method_calls)
+ self.assertMultiLineEqual(pp1+'\n', pp2+'\n')
def cmd_help(self, args, help_msg=None, topic=None, ret=ERR):
"""Run a command line, and check that it prints the right help.
@@ -83,7 +93,7 @@ class ClassicCmdLineTest(CmdLineTest):
def testErase(self):
# coverage -e
self.cmd_executes("-e", """\
- .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None, config_file=True)
+ .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True)
.erase()
""")
self.cmd_executes_same("-e", "--erase")
@@ -93,7 +103,7 @@ class ClassicCmdLineTest(CmdLineTest):
# -x calls coverage.load first.
self.cmd_executes("-x foo.py", """\
- .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None, config_file=True)
+ .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True)
.load()
.start()
.run_python_file('foo.py', ['foo.py'])
@@ -102,7 +112,7 @@ class ClassicCmdLineTest(CmdLineTest):
""")
# -e -x calls coverage.erase first.
self.cmd_executes("-e -x foo.py", """\
- .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None, config_file=True)
+ .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True)
.erase()
.start()
.run_python_file('foo.py', ['foo.py'])
@@ -111,7 +121,7 @@ class ClassicCmdLineTest(CmdLineTest):
""")
# --timid sets a flag, and program arguments get passed through.
self.cmd_executes("-x --timid foo.py abc 123", """\
- .coverage(cover_pylib=None, data_suffix=False, timid=True, branch=None, config_file=True)
+ .coverage(cover_pylib=None, data_suffix=None, timid=True, branch=None, config_file=True)
.load()
.start()
.run_python_file('foo.py', ['foo.py', 'abc', '123'])
@@ -137,7 +147,7 @@ class ClassicCmdLineTest(CmdLineTest):
def testCombine(self):
# coverage -c
self.cmd_executes("-c", """\
- .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None, config_file=True)
+ .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True)
.load()
.combine()
.save()
@@ -440,7 +450,7 @@ class NewCmdLineTest(CmdLineTest):
self.cmd_executes_same("run --timid f.py", "-e -x --timid f.py")
self.cmd_executes_same("run", "-x")
self.cmd_executes("run --branch foo.py", """\
- .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=True, config_file=True)
+ .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=True, config_file=True)
.erase()
.start()
.run_python_file('foo.py', ['foo.py'])
@@ -448,7 +458,7 @@ class NewCmdLineTest(CmdLineTest):
.save()
""")
self.cmd_executes("run --rcfile=myrc.rc foo.py", """\
- .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None, config_file="myrc.rc")
+ .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file="myrc.rc")
.erase()
.start()
.run_python_file('foo.py', ['foo.py'])