diff options
-rw-r--r-- | coverage/cmdline.py | 2 | ||||
-rw-r--r-- | tests/test_cmdline.py | 118 |
2 files changed, 59 insertions, 61 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 5b15813..a9af9f3 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -460,7 +460,7 @@ class CoverageScript(object): debug = unshell_list(options.debug) # Do something. - self.coverage = self.covpkg.coverage( + self.coverage = self.covpkg.Coverage( data_suffix=options.parallel_mode, cover_pylib=options.pylib, timid=options.timid, diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index a9b02bc..000bf46 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -29,7 +29,7 @@ class BaseCmdLineTest(CoverageTest): # Make a dict mapping function names to the default values that cmdline.py # uses when calling the function. defaults = mock.Mock() - defaults.coverage( + defaults.Coverage( cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True, source=None, include=None, omit=None, debug=None, concurrency=None, @@ -54,9 +54,9 @@ class BaseCmdLineTest(CoverageTest): def model_object(self): """Return a Mock suitable for use in CoverageScript.""" mk = mock.Mock() - # We'll invoke .coverage as the constructor, and then keep using the + # We'll invoke .Coverage as the constructor, and then keep using the # same object as the resulting coverage object. - mk.coverage.return_value = mk + mk.Coverage.return_value = mk # The mock needs to get options, but shouldn't need to set them. config = CoverageConfig() @@ -152,37 +152,37 @@ class CmdLineTest(BaseCmdLineTest): def test_annotate(self): # coverage annotate [-d DIR] [-i] [--omit DIR,...] [FILE1 FILE2 ...] self.cmd_executes("annotate", """\ - .coverage() + .Coverage() .load() .annotate() """) self.cmd_executes("annotate -d dir1", """\ - .coverage() + .Coverage() .load() .annotate(directory="dir1") """) self.cmd_executes("annotate -i", """\ - .coverage() + .Coverage() .load() .annotate(ignore_errors=True) """) self.cmd_executes("annotate --omit fooey", """\ - .coverage(omit=["fooey"]) + .Coverage(omit=["fooey"]) .load() .annotate(omit=["fooey"]) """) self.cmd_executes("annotate --omit fooey,booey", """\ - .coverage(omit=["fooey", "booey"]) + .Coverage(omit=["fooey", "booey"]) .load() .annotate(omit=["fooey", "booey"]) """) self.cmd_executes("annotate mod1", """\ - .coverage() + .Coverage() .load() .annotate(morfs=["mod1"]) """) self.cmd_executes("annotate mod1 mod2 mod3", """\ - .coverage() + .Coverage() .load() .annotate(morfs=["mod1", "mod2", "mod3"]) """) @@ -190,20 +190,20 @@ class CmdLineTest(BaseCmdLineTest): def test_combine(self): # coverage combine with args self.cmd_executes("combine datadir1", """\ - .coverage() + .Coverage() .combine(["datadir1"], strict=True) .save() """) # coverage combine, appending self.cmd_executes("combine --append datadir1", """\ - .coverage() + .Coverage() .load() .combine(["datadir1"], strict=True) .save() """) # coverage combine without args self.cmd_executes("combine", """\ - .coverage() + .Coverage() .combine(None, strict=True) .save() """) @@ -211,12 +211,12 @@ class CmdLineTest(BaseCmdLineTest): def test_combine_doesnt_confuse_options_with_args(self): # https://bitbucket.org/ned/coveragepy/issues/385/coverage-combine-doesnt-work-with-rcfile self.cmd_executes("combine --rcfile cov.ini", """\ - .coverage(config_file='cov.ini') + .Coverage(config_file='cov.ini') .combine(None, strict=True) .save() """) self.cmd_executes("combine --rcfile cov.ini data1 data2/more", """\ - .coverage(config_file='cov.ini') + .Coverage(config_file='cov.ini') .combine(["data1", "data2/more"], strict=True) .save() """) @@ -240,7 +240,7 @@ class CmdLineTest(BaseCmdLineTest): def test_erase(self): # coverage erase self.cmd_executes("erase", """\ - .coverage() + .Coverage() .erase() """) @@ -263,42 +263,42 @@ class CmdLineTest(BaseCmdLineTest): def test_html(self): # coverage html -d DIR [-i] [--omit DIR,...] [FILE1 FILE2 ...] self.cmd_executes("html", """\ - .coverage() + .Coverage() .load() .html_report() """) self.cmd_executes("html -d dir1", """\ - .coverage() + .Coverage() .load() .html_report(directory="dir1") """) self.cmd_executes("html -i", """\ - .coverage() + .Coverage() .load() .html_report(ignore_errors=True) """) self.cmd_executes("html --omit fooey", """\ - .coverage(omit=["fooey"]) + .Coverage(omit=["fooey"]) .load() .html_report(omit=["fooey"]) """) self.cmd_executes("html --omit fooey,booey", """\ - .coverage(omit=["fooey", "booey"]) + .Coverage(omit=["fooey", "booey"]) .load() .html_report(omit=["fooey", "booey"]) """) self.cmd_executes("html mod1", """\ - .coverage() + .Coverage() .load() .html_report(morfs=["mod1"]) """) self.cmd_executes("html mod1 mod2 mod3", """\ - .coverage() + .Coverage() .load() .html_report(morfs=["mod1", "mod2", "mod3"]) """) self.cmd_executes("html --title=Hello_there", """\ - .coverage() + .Coverage() .load() .html_report(title='Hello_there') """) @@ -306,42 +306,42 @@ class CmdLineTest(BaseCmdLineTest): def test_report(self): # coverage report [-m] [-i] [-o DIR,...] [FILE1 FILE2 ...] self.cmd_executes("report", """\ - .coverage() + .Coverage() .load() .report(show_missing=None) """) self.cmd_executes("report -i", """\ - .coverage() + .Coverage() .load() .report(ignore_errors=True) """) self.cmd_executes("report -m", """\ - .coverage() + .Coverage() .load() .report(show_missing=True) """) self.cmd_executes("report --omit fooey", """\ - .coverage(omit=["fooey"]) + .Coverage(omit=["fooey"]) .load() .report(omit=["fooey"]) """) self.cmd_executes("report --omit fooey,booey", """\ - .coverage(omit=["fooey", "booey"]) + .Coverage(omit=["fooey", "booey"]) .load() .report(omit=["fooey", "booey"]) """) self.cmd_executes("report mod1", """\ - .coverage() + .Coverage() .load() .report(morfs=["mod1"]) """) self.cmd_executes("report mod1 mod2 mod3", """\ - .coverage() + .Coverage() .load() .report(morfs=["mod1", "mod2", "mod3"]) """) self.cmd_executes("report --skip-covered", """\ - .coverage() + .Coverage() .load() .report(skip_covered=True) """) @@ -351,7 +351,7 @@ class CmdLineTest(BaseCmdLineTest): # run calls coverage.erase first. self.cmd_executes("run foo.py", """\ - .coverage() + .Coverage() .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -360,7 +360,7 @@ class CmdLineTest(BaseCmdLineTest): """) # run -a combines with an existing data file before saving. self.cmd_executes("run -a foo.py", """\ - .coverage() + .Coverage() .start() .run_python_file('foo.py', ['foo.py']) .stop() @@ -370,7 +370,7 @@ class CmdLineTest(BaseCmdLineTest): """, path_exists=True) # run -a doesn't combine anything if the data file doesn't exist. self.cmd_executes("run -a foo.py", """\ - .coverage() + .Coverage() .start() .run_python_file('foo.py', ['foo.py']) .stop() @@ -379,7 +379,7 @@ class CmdLineTest(BaseCmdLineTest): """, path_exists=False) # --timid sets a flag, and program arguments get passed through. self.cmd_executes("run --timid foo.py abc 123", """\ - .coverage(timid=True) + .Coverage(timid=True) .erase() .start() .run_python_file('foo.py', ['foo.py', 'abc', '123']) @@ -388,7 +388,7 @@ class CmdLineTest(BaseCmdLineTest): """) # -L sets a flag, and flags for the program don't confuse us. self.cmd_executes("run -p -L foo.py -a -b", """\ - .coverage(cover_pylib=True, data_suffix=True) + .Coverage(cover_pylib=True, data_suffix=True) .erase() .start() .run_python_file('foo.py', ['foo.py', '-a', '-b']) @@ -396,7 +396,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --branch foo.py", """\ - .coverage(branch=True) + .Coverage(branch=True) .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -404,7 +404,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --rcfile=myrc.rc foo.py", """\ - .coverage(config_file="myrc.rc") + .Coverage(config_file="myrc.rc") .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -412,7 +412,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --include=pre1,pre2 foo.py", """\ - .coverage(include=["pre1", "pre2"]) + .Coverage(include=["pre1", "pre2"]) .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -420,7 +420,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --omit=opre1,opre2 foo.py", """\ - .coverage(omit=["opre1", "opre2"]) + .Coverage(omit=["opre1", "opre2"]) .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -428,7 +428,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --include=pre1,pre2 --omit=opre1,opre2 foo.py", """\ - .coverage(include=["pre1", "pre2"], omit=["opre1", "opre2"]) + .Coverage(include=["pre1", "pre2"], omit=["opre1", "opre2"]) .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -436,7 +436,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --source=quux,hi.there,/home/bar foo.py", """\ - .coverage(source=["quux", "hi.there", "/home/bar"]) + .Coverage(source=["quux", "hi.there", "/home/bar"]) .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -444,7 +444,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --concurrency=gevent foo.py", """\ - .coverage(concurrency='gevent') + .Coverage(concurrency='gevent') .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -452,7 +452,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --concurrency=multiprocessing foo.py", """\ - .coverage(concurrency='multiprocessing') + .Coverage(concurrency='multiprocessing') .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -485,7 +485,7 @@ class CmdLineTest(BaseCmdLineTest): def test_run_debug(self): self.cmd_executes("run --debug=opt1 foo.py", """\ - .coverage(debug=["opt1"]) + .Coverage(debug=["opt1"]) .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -493,7 +493,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --debug=opt1,opt2 foo.py", """\ - .coverage(debug=["opt1","opt2"]) + .Coverage(debug=["opt1","opt2"]) .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -503,7 +503,7 @@ class CmdLineTest(BaseCmdLineTest): def test_run_module(self): self.cmd_executes("run -m mymodule", """\ - .coverage() + .Coverage() .erase() .start() .run_python_module('mymodule', ['mymodule']) @@ -511,7 +511,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run -m mymodule -qq arg1 arg2", """\ - .coverage() + .Coverage() .erase() .start() .run_python_module('mymodule', ['mymodule', '-qq', 'arg1', 'arg2']) @@ -519,7 +519,7 @@ class CmdLineTest(BaseCmdLineTest): .save() """) self.cmd_executes("run --branch -m mymodule", """\ - .coverage(branch=True) + .Coverage(branch=True) .erase() .start() .run_python_module('mymodule', ['mymodule']) @@ -539,42 +539,42 @@ class CmdLineTest(BaseCmdLineTest): def test_xml(self): # coverage xml [-i] [--omit DIR,...] [FILE1 FILE2 ...] self.cmd_executes("xml", """\ - .coverage() + .Coverage() .load() .xml_report() """) self.cmd_executes("xml -i", """\ - .coverage() + .Coverage() .load() .xml_report(ignore_errors=True) """) self.cmd_executes("xml -o myxml.foo", """\ - .coverage() + .Coverage() .load() .xml_report(outfile="myxml.foo") """) self.cmd_executes("xml -o -", """\ - .coverage() + .Coverage() .load() .xml_report(outfile="-") """) self.cmd_executes("xml --omit fooey", """\ - .coverage(omit=["fooey"]) + .Coverage(omit=["fooey"]) .load() .xml_report(omit=["fooey"]) """) self.cmd_executes("xml --omit fooey,booey", """\ - .coverage(omit=["fooey", "booey"]) + .Coverage(omit=["fooey", "booey"]) .load() .xml_report(omit=["fooey", "booey"]) """) self.cmd_executes("xml mod1", """\ - .coverage() + .Coverage() .load() .xml_report(morfs=["mod1"]) """) self.cmd_executes("xml mod1 mod2 mod3", """\ - .coverage() + .Coverage() .load() .xml_report(morfs=["mod1", "mod2", "mod3"]) """) @@ -732,8 +732,6 @@ class CoverageReportingFake(object): def Coverage(self, *args_unused, **kwargs_unused): return self - coverage = Coverage # shouldn't need this... - def set_option(self, optname, optvalue): setattr(self, optname, optvalue) |