diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 4 | ||||
-rw-r--r-- | tests/helpers.py | 4 | ||||
-rw-r--r-- | tests/test_annotate.py | 2 | ||||
-rw-r--r-- | tests/test_api.py | 4 | ||||
-rw-r--r-- | tests/test_arcs.py | 32 | ||||
-rw-r--r-- | tests/test_cmdline.py | 12 | ||||
-rw-r--r-- | tests/test_coverage.py | 14 | ||||
-rw-r--r-- | tests/test_data.py | 2 | ||||
-rw-r--r-- | tests/test_files.py | 4 | ||||
-rw-r--r-- | tests/test_html.py | 8 | ||||
-rw-r--r-- | tests/test_json.py | 18 | ||||
-rw-r--r-- | tests/test_numbits.py | 2 | ||||
-rw-r--r-- | tests/test_oddball.py | 12 | ||||
-rw-r--r-- | tests/test_parser.py | 10 | ||||
-rw-r--r-- | tests/test_plugins.py | 10 | ||||
-rw-r--r-- | tests/test_process.py | 4 | ||||
-rw-r--r-- | tests/test_results.py | 6 | ||||
-rw-r--r-- | tests/test_setup.py | 2 | ||||
-rw-r--r-- | tests/test_summary.py | 2 | ||||
-rw-r--r-- | tests/test_templite.py | 46 | ||||
-rw-r--r-- | tests/test_venv.py | 18 | ||||
-rw-r--r-- | tests/test_xml.py | 14 |
22 files changed, 115 insertions, 115 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 39f39e25..03b51b2c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -43,12 +43,12 @@ def set_warnings(): "ignore", category=DeprecationWarning, message=r".*imp module is deprecated in favour of importlib", - ) + ) warnings.filterwarnings( "ignore", category=pytest.PytestRemovedIn8Warning, - ) + ) if env.PYPY: # pypy3 warns about unclosed files a lot. diff --git a/tests/helpers.py b/tests/helpers.py index 890bd7c5..3d177824 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -45,7 +45,7 @@ def run_command(cmd): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT - ) + ) output, _ = proc.communicate() status = proc.returncode @@ -135,7 +135,7 @@ class CheckUniqueFilenames: """The replacement method. Check that we don't have dupes.""" assert filename not in self.filenames, ( f"File name {filename!r} passed to {self.wrapped!r} twice" - ) + ) self.filenames.add(filename) ret = self.wrapped(filename, *args, **kwargs) return ret diff --git a/tests/test_annotate.py b/tests/test_annotate.py index 09893143..e2d49f25 100644 --- a/tests/test_annotate.py +++ b/tests/test_annotate.py @@ -128,5 +128,5 @@ class AnnotationGoldTest(CoverageTest): "2\n" + "The annotate command will be removed in a future version.\n" + "Get in touch if you still use it: ned@nedbatchelder.com\n" - ) + ) compare(gold_path("annotate/mae"), ".", "*,cover") diff --git a/tests/test_api.py b/tests/test_api.py index bc2d05f6..63bb9abc 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -540,7 +540,7 @@ class ApiTest(CoverageTest): "Module xyzzy was never imported. (module-not-imported)", "Module quux was never imported. (module-not-imported)", "No data was collected. (no-data-collected)", - ) + ) def test_warnings_suppressed(self): self.make_file("hello.py", """\ @@ -1225,7 +1225,7 @@ class RelativePathTest(CoverageTest): config_file=".coveragerc", concurrency="multiprocessing", data_suffix=False, - ) + ) cov.start() cov.stop() # The warning isn't the point of this test, but suppress it. diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 10157a77..c2ae7847 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -135,7 +135,7 @@ class SimpleArcTest(CoverageTest): assert foo() == 3 # 7 """, arcz=".1 17 7. .2 23 36 25 56 6.", arcz_missing="25 56" - ) + ) self.check_coverage("""\ def foo(): if foo: @@ -145,7 +145,7 @@ class SimpleArcTest(CoverageTest): foo() # 6 """, arcz=".1 16 6. .2 23 3. 25 5.", arcz_missing="25 5." - ) + ) def test_what_is_the_sound_of_no_lines_clapping(self): if env.JYTHON: @@ -176,7 +176,7 @@ class SimpleArcTest(CoverageTest): """, arcz=".1 19 9-1 .2 23 27 34 47 56 67 7-1 9A A9", arcz_unpredicted="45", - ) + ) class WithTest(CoverageTest): @@ -195,7 +195,7 @@ class WithTest(CoverageTest): example() """, arcz=arcz, - ) + ) def test_with_return(self): arcz = ".1 .2 23 34 4. 16 6." @@ -210,7 +210,7 @@ class WithTest(CoverageTest): example() """, arcz=arcz, - ) + ) def test_bug_146(self): # https://github.com/nedbat/coveragepy/issues/146 @@ -225,7 +225,7 @@ class WithTest(CoverageTest): print(5) """, arcz=arcz, - ) + ) def test_nested_with_return(self): arcz = ".1 .2 23 34 45 56 6. 18 8." @@ -242,7 +242,7 @@ class WithTest(CoverageTest): example(8) """, arcz=arcz, - ) + ) def test_break_through_with(self): arcz = ".1 12 23 34 45 15 5." @@ -257,7 +257,7 @@ class WithTest(CoverageTest): """, arcz=arcz, arcz_missing="15", - ) + ) def test_continue_through_with(self): arcz = ".1 12 23 34 41 15 5." @@ -271,7 +271,7 @@ class WithTest(CoverageTest): print(5) """, arcz=arcz, - ) + ) @pytest.mark.xfail( (3, 11) <= env.PYVERSION <= (3, 11, 0, 'alpha', 2, 0), @@ -302,7 +302,7 @@ class WithTest(CoverageTest): arcz=arcz, arcz_missing=arcz_missing, arcz_unpredicted=arcz_unpredicted, - ) + ) expected = "line 3 didn't jump to the function exit" assert self.get_missing_arc_description(cov, 3, -2) == expected @@ -328,7 +328,7 @@ class WithTest(CoverageTest): """, arcz=arcz, arcz_missing=arcz_missing, - ) + ) expected = "line 3 didn't jump to the function exit" assert self.get_missing_arc_description(cov, 3, -2) == expected @@ -428,7 +428,7 @@ class LoopArcTest(CoverageTest): assert a == 4 and i == 3 """, arcz=arcz, - ) + ) def test_while_true(self): # With "while True", 2.x thinks it's computation, @@ -492,7 +492,7 @@ class LoopArcTest(CoverageTest): break """, arcz=arcz - ) + ) def test_for_if_else_for(self): self.check_coverage("""\ @@ -519,7 +519,7 @@ class LoopArcTest(CoverageTest): ".2 23 34 43 26 3. 6. " + "-89 9A 9-8 AB BC CB B9 AE E9", arcz_missing="26 6." - ) + ) def test_for_else(self): self.check_coverage("""\ @@ -534,7 +534,7 @@ class LoopArcTest(CoverageTest): forelse([1,6]) """, arcz=".1 .2 23 32 34 47 26 67 7. 18 89 9." - ) + ) def test_while_else(self): self.check_coverage("""\ @@ -1777,7 +1777,7 @@ class LambdaArcTest(CoverageTest): b = 3 """, arcz=".1 12 -22 2-2 23 3.", arcz_missing="-22 2-2", - ) + ) def test_raise_with_lambda_looks_like_partial_branch(self): self.check_coverage("""\ diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index a088ab8a..c147b527 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -107,7 +107,7 @@ class BaseCmdLineTest(CoverageTest): patchers = [ mock.patch("coverage.cmdline."+name, getattr(mk, name)) for name in self.MOCK_GLOBALS - ] + ] for patcher in patchers: patcher.start() try: @@ -797,7 +797,7 @@ class CmdLineTest(BaseCmdLineTest): cov.save() """, options=options, - ) + ) def test_run_module_from_config(self): self.cmd_executes("run", """\ @@ -810,7 +810,7 @@ class CmdLineTest(BaseCmdLineTest): cov.save() """, options={"run:command_line": "-m mymodule thing1 thing2"}, - ) + ) def test_run_from_config_but_empty(self): self.cmd_executes("run", """\ @@ -819,7 +819,7 @@ class CmdLineTest(BaseCmdLineTest): """, ret=ERR, options={"run:command_line": ""}, - ) + ) def test_run_dashm_only(self): self.cmd_executes("run -m", """\ @@ -827,14 +827,14 @@ class CmdLineTest(BaseCmdLineTest): show_help('No module specified for -m') """, ret=ERR, - ) + ) self.cmd_executes("run -m", """\ cov = Coverage() show_help('No module specified for -m') """, ret=ERR, options={"run:command_line": "myprog.py"} - ) + ) def test_cant_append_parallel(self): self.command_line("run --append --parallel-mode foo.py", ret=ERR) diff --git a/tests/test_coverage.py b/tests/test_coverage.py index fc4263de..9164db0f 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -22,14 +22,14 @@ class TestCoverageTest(CoverageTest): b = 2 """, [1,2] - ) + ) # You can provide a list of possible statement matches. self.check_coverage("""\ a = 1 b = 2 """, ([100], [1,2], [1723,47]), - ) + ) # You can specify missing lines. self.check_coverage("""\ a = 1 @@ -38,7 +38,7 @@ class TestCoverageTest(CoverageTest): """, [1,2,3], missing="3", - ) + ) # You can specify a list of possible missing lines. self.check_coverage("""\ a = 1 @@ -47,7 +47,7 @@ class TestCoverageTest(CoverageTest): """, [1,2,3], missing=("47-49", "3", "100,102") - ) + ) def test_failed_coverage(self): # If the lines are wrong, the message shows right and wrong. @@ -96,7 +96,7 @@ class TestCoverageTest(CoverageTest): a = 1 assert a == 99, "This is bad" """ - ) + ) # Other exceptions too. with pytest.raises(ZeroDivisionError, match="division"): self.check_coverage("""\ @@ -104,7 +104,7 @@ class TestCoverageTest(CoverageTest): assert a == 1, "This is good" a/0 """ - ) + ) class BasicCoverageTest(CoverageTest): @@ -1256,7 +1256,7 @@ class ExcludeTest(CoverageTest): g = 7 """, [1,3,5,7] - ) + ) def test_simple(self): self.check_coverage("""\ diff --git a/tests/test_data.py b/tests/test_data.py index f9928467..f8bff2eb 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -888,6 +888,6 @@ class DumpsLoadsTest(CoverageTest): msg = r"Unrecognized serialization: {} \(head of {} bytes\)".format( re.escape(repr(bad_data[:40])), len(bad_data), - ) + ) with pytest.raises(DataError, match=msg): covdata.loads(bad_data) diff --git a/tests/test_files.py b/tests/test_files.py index 0780fdb3..5588c373 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -170,7 +170,7 @@ class MatcherTest(CoverageTest): files.canonical_filename("sub3/file4.py"), files.canonical_filename("sub4/file5.py"), files.canonical_filename("SUB5/file6.py"), - ] + ] tm = TreeMatcher(trees) assert tm.info() == sorted(trees) for filepath, matches in matches_to_try: @@ -418,7 +418,7 @@ class FindPythonFilesTest(CoverageTest): "sub/a.py", "sub/b.py", "sub/ssub/__init__.py", "sub/ssub/s.py", "sub/windows.pyw", - ]) + ]) @pytest.mark.skipif(not env.WINDOWS, reason="Only need to run Windows tests on Windows.") diff --git a/tests/test_html.py b/tests/test_html.py index 797fee1d..b1951cdb 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -363,7 +363,7 @@ class HtmlWithUnparsableFilesTest(HtmlTestHelpers, CoverageTest): assert_coverage_warnings( warns, re.compile(r"Couldn't parse Python file '.*innocuous.py' \(couldnt-parse\)"), - ) + ) self.assert_exists("htmlcov/index.html") # This would be better as a glob, if the HTML layout changes: self.assert_doesnt_exist("htmlcov/innocuous.html") @@ -868,8 +868,8 @@ assert len(math) == 18 gold_path("html/other"), "out/other", extra_scrubs=[ (r'href="d_[0-9a-z]{16}_', 'href="_TEST_TMPDIR_othersrc_'), - ], - ) + ], + ) contains( 'out/other/index.html', '<a href="here_py.html">here.py</a>', @@ -1096,7 +1096,7 @@ class HtmlWithContextsTest(HtmlTestHelpers, CoverageTest): assert b == (14-4) helper( 16 - ) + ) test_one() x = 20 diff --git a/tests/test_json.py b/tests/test_json.py index b750a666..63713af8 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -57,8 +57,8 @@ class JsonReportTest(UsingModulesMixin, CoverageTest): 'missing_branches': 1, 'percent_covered': 60.0, 'percent_covered_display': '60', - } - } + }, + }, }, 'totals': { 'missing_lines': 1, @@ -71,7 +71,7 @@ class JsonReportTest(UsingModulesMixin, CoverageTest): 'percent_covered_display': '60', 'covered_branches': 1, 'missing_branches': 1, - } + }, } self._assert_expected_json_report(cov, expected_result) @@ -95,8 +95,8 @@ class JsonReportTest(UsingModulesMixin, CoverageTest): 'num_statements': 3, 'percent_covered': 66.66666666666667, 'percent_covered_display': '67', - } - } + }, + }, }, 'totals': { 'excluded_lines': 0, @@ -105,7 +105,7 @@ class JsonReportTest(UsingModulesMixin, CoverageTest): 'num_statements': 3, 'percent_covered': 66.66666666666667, 'percent_covered_display': '67', - } + }, } self._assert_expected_json_report(cov, expected_result) @@ -148,8 +148,8 @@ class JsonReportTest(UsingModulesMixin, CoverageTest): 'num_statements': 3, 'percent_covered': 66.66666666666667, 'percent_covered_display': '66.67', - } - } + }, + }, }, 'totals': { 'excluded_lines': 0, @@ -158,7 +158,7 @@ class JsonReportTest(UsingModulesMixin, CoverageTest): 'num_statements': 3, 'percent_covered': 66.66666666666667, 'percent_covered_display': '66.67', - } + }, } self._assert_expected_json_report(cov, expected_result) diff --git a/tests/test_numbits.py b/tests/test_numbits.py index 359097b6..39cb93f6 100644 --- a/tests/test_numbits.py +++ b/tests/test_numbits.py @@ -13,7 +13,7 @@ from coverage import env from coverage.numbits import ( nums_to_numbits, numbits_to_nums, numbits_union, numbits_intersection, numbits_any_intersection, num_in_numbits, register_sqlite_functions, - ) +) from tests.coveragetest import CoverageTest diff --git a/tests/test_oddball.py b/tests/test_oddball.py index 703e8187..15dae128 100644 --- a/tests/test_oddball.py +++ b/tests/test_oddball.py @@ -94,7 +94,7 @@ class RecursionTest(CoverageTest): recur(100000) # This is definitely too many frames. """, [1, 2, 3, 5, 7], "" - ) + ) def test_long_recursion_recovery(self): # Test the core of bug 93: https://github.com/nedbat/coveragepy/issues/93 @@ -346,25 +346,25 @@ class ExceptionTest(CoverageTest): 'doit.py': [302, 303, 304, 305], 'fly.py': [102, 103], 'oops.py': [2, 3], - }), + }), ("doit catch oops", { 'doit.py': [302, 303], 'catch.py': [202, 203, 204, 206, 207], 'oops.py': [2, 3], - }), + }), ("doit fly catch oops", { 'doit.py': [302, 303], 'fly.py': [102, 103, 104], 'catch.py': [202, 203, 204, 206, 207], 'oops.py': [2, 3], - }), + }), ("doit catch fly oops", { 'doit.py': [302, 303], 'catch.py': [202, 203, 204, 206, 207], 'fly.py': [102, 103], 'oops.py': [2, 3], - }), - ] + }), + ] for callnames, lines_expected in runs: diff --git a/tests/test_parser.py b/tests/test_parser.py index 29c93035..cc5d6ba0 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -44,7 +44,7 @@ class PythonParserTest(CoverageTest): """) assert parser.exit_counts() == { 2:2, 3:1, 4:2, 5:1, 7:1, 9:2, 10:1 - } + } def test_generator_exit_counts(self): # https://github.com/nedbat/coveragepy/issues/324 @@ -76,7 +76,7 @@ class PythonParserTest(CoverageTest): """) assert parser.exit_counts() == { 1: 1, 2:1, 3:2, 4:1, 5:2, 6:1, 7:1, 8:1, 9:1 - } + } def test_excluded_classes(self): parser = self.parse_source("""\ @@ -90,7 +90,7 @@ class PythonParserTest(CoverageTest): """) assert parser.exit_counts() == { 1:1, 2:1, 3:1 - } + } def test_missing_branch_to_excluded_code(self): parser = self.parse_source("""\ @@ -433,10 +433,10 @@ class ParserMissingArcDescriptionTest(CoverageTest): """) assert parser.missing_arc_description(3, 4) == ( "line 3 didn't jump to line 4, because the pattern on line 3 never matched" - ) + ) assert parser.missing_arc_description(3, 5) == ( "line 3 didn't jump to line 5, because the pattern on line 3 always matched" - ) + ) class ParserFileTest(CoverageTest): diff --git a/tests/test_plugins.py b/tests/test_plugins.py index edf849f6..b4239700 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -196,7 +196,7 @@ class PluginTest(CoverageTest): cov.set_option("run:plugins", ["plugin_sys_info"]) with swallow_warnings( r"Plugin file tracers \(plugin_sys_info.Plugin\) aren't supported with PyTracer" - ): + ): cov.start() cov.stop() # pragma: nested @@ -210,7 +210,7 @@ class PluginTest(CoverageTest): "-- sys: plugin_sys_info.Plugin -------------------------------", "hello: world", "-- end -------------------------------------------------------", - ] + ] assert expected_end == out_lines[-len(expected_end):] def test_plugin_with_no_sys_info(self): @@ -236,7 +236,7 @@ class PluginTest(CoverageTest): expected_end = [ "-- sys: plugin_no_sys_info.Plugin ----------------------------", "-- end -------------------------------------------------------", - ] + ] assert expected_end == out_lines[-len(expected_end):] def test_local_files_are_importable(self): @@ -426,7 +426,7 @@ class GoodFileTracerTest(FileTracerTest): 'foo_7.html 7 5 0 0 29% 1-3, 6-7', '--------------------------------------------------------', 'TOTAL 11 7 0 0 36%', - ] + ] assert expected == report assert math.isclose(total, 4 / 11 * 100) @@ -525,7 +525,7 @@ class GoodFileTracerTest(FileTracerTest): 'unsuspecting.py 6 3 50% 2, 4, 6', '-----------------------------------------------', 'TOTAL 6 3 50%', - ] + ] assert expected == report assert total == 50 diff --git a/tests/test_process.py b/tests/test_process.py index eac3ddda..c473cf9a 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -826,7 +826,7 @@ class EnvironmentTest(CoverageTest): sys.path[0:0] = [ r'{abc}', '/Users/somebody/temp/something/eggs/something-4.5.1-py2.7-xxx-10.13-x86_64.egg', - ] + ] import coverage.cmdline @@ -1076,7 +1076,7 @@ class FailUnderTest(CoverageTest): "b = 2\n" * 2000 + "if a > 3:\n" + " c = 4\n" - ) + ) self.make_data_file(lines={abs_file("ninety_nine_plus.py"): range(1, 2002)}) st, out = self.run_command_status("coverage report --fail-under=100") assert st == 2 diff --git a/tests/test_results.py b/tests/test_results.py index 4138ffd4..41f3dc40 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -139,19 +139,19 @@ def test_format_lines(statements, lines, result): {1,2,5,10,11,13,14}, (), "1-2, 5-11, 13-14" - ), + ), ( [1,2,3,4,5,10,11,12,13,14,98,99], [1,2,5,10,11,13,14,99], [(3, [4]), (5, [10, 11]), (98, [100, -1])], "1-2, 3->4, 5-11, 13-14, 98->100, 98->exit, 99" - ), + ), ( [1,2,3,4,98,99,100,101,102,103,104], [1,2,99,102,103,104], [(3, [4]), (104, [-1])], "1-2, 3->4, 99, 102-104" - ), + ), ]) def test_format_lines_with_arcs(statements, lines, arcs, result): assert format_lines(statements, lines, arcs) == result diff --git a/tests/test_setup.py b/tests/test_setup.py index aa65af78..5468e3bf 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -23,7 +23,7 @@ class SetupPyTest(CoverageTest): def test_metadata(self): status, output = self.run_command_status( "python setup.py --description --version --url --author" - ) + ) assert status == 0 out = output.splitlines() assert "measurement" in out[0] diff --git a/tests/test_summary.py b/tests/test_summary.py index 7e8f2919..4bce80f6 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -597,7 +597,7 @@ class SummaryTest(UsingModulesMixin, CoverageTest): assert_coverage_warnings( warns, re.compile(r"Couldn't parse Python file '.*[/\\]mycode.py' \(couldnt-parse\)"), - ) + ) def test_dothtml_not_python(self): # We run a .html file, and when reporting, we can't parse it as diff --git a/tests/test_templite.py b/tests/test_templite.py index 0f86690b..d2e98479 100644 --- a/tests/test_templite.py +++ b/tests/test_templite.py @@ -71,7 +71,7 @@ class TempliteTest(CoverageTest): 'name': 'Ned', 'upper': lambda x: x.upper(), 'second': lambda x: x[1], - } + } self.try_render("Hello, {{name|upper}}!", data, "Hello, NED!") # Pipes can be concatenated. @@ -82,7 +82,7 @@ class TempliteTest(CoverageTest): globs = { 'upper': lambda x: x.upper(), 'punct': '!', - } + } template = Templite("This is {{name|upper}}{{punct}}", globs) assert template.render({'name':'Ned'}) == "This is NED!" @@ -118,7 +118,7 @@ class TempliteTest(CoverageTest): "Look: {% for n in nums %}{{n}}, {% endfor %}done.", locals(), "Look: 1, 2, 3, 4, done." - ) + ) # Loop iterables can be filtered. def rev(l): """Return the reverse of `l`.""" @@ -130,21 +130,21 @@ class TempliteTest(CoverageTest): "Look: {% for n in nums|rev %}{{n}}, {% endfor %}done.", locals(), "Look: 4, 3, 2, 1, done." - ) + ) def test_empty_loops(self): self.try_render( "Empty: {% for n in nums %}{{n}}, {% endfor %}done.", {'nums':[]}, "Empty: done." - ) + ) def test_multiline_loops(self): self.try_render( "Look: \n{% for n in nums %}\n{{n}}, \n{% endfor %}done.", {'nums':[1,2,3]}, "Look: \n\n1, \n\n2, \n\n3, \ndone." - ) + ) def test_multiple_loops(self): self.try_render( @@ -152,46 +152,46 @@ class TempliteTest(CoverageTest): "{% for n in nums %}{{n}}{% endfor %}", {'nums': [1,2,3]}, "123 and 123" - ) + ) def test_comments(self): # Single-line comments work: self.try_render( "Hello, {# Name goes here: #}{{name}}!", {'name':'Ned'}, "Hello, Ned!" - ) + ) # and so do multi-line comments: self.try_render( "Hello, {# Name\ngoes\nhere: #}{{name}}!", {'name':'Ned'}, "Hello, Ned!" - ) + ) def test_if(self): self.try_render( "Hi, {% if ned %}NED{% endif %}{% if ben %}BEN{% endif %}!", {'ned': 1, 'ben': 0}, "Hi, NED!" - ) + ) self.try_render( "Hi, {% if ned %}NED{% endif %}{% if ben %}BEN{% endif %}!", {'ned': 0, 'ben': 1}, "Hi, BEN!" - ) + ) self.try_render( "Hi, {% if ned %}NED{% if ben %}BEN{% endif %}{% endif %}!", {'ned': 0, 'ben': 0}, "Hi, !" - ) + ) self.try_render( "Hi, {% if ned %}NED{% if ben %}BEN{% endif %}{% endif %}!", {'ned': 1, 'ben': 0}, "Hi, NED!" - ) + ) self.try_render( "Hi, {% if ned %}NED{% if ben %}BEN{% endif %}{% endif %}!", {'ned': 1, 'ben': 1}, "Hi, NEDBEN!" - ) + ) def test_complex_if(self): class Complex(AnyOldObject): @@ -208,24 +208,24 @@ class TempliteTest(CoverageTest): "!", { 'obj': obj, 'str': str }, "@XS!" - ) + ) def test_loop_if(self): self.try_render( "@{% for n in nums %}{% if n %}Z{% endif %}{{n}}{% endfor %}!", {'nums': [0,1,2]}, "@0Z1Z2!" - ) + ) self.try_render( "X{%if nums%}@{% for n in nums %}{{n}}{% endfor %}{%endif%}!", {'nums': [0,1,2]}, "X@012!" - ) + ) self.try_render( "X{%if nums%}@{% for n in nums %}{{n}}{% endfor %}{%endif%}!", {'nums': []}, "X!" - ) + ) def test_nested_loops(self): self.try_render( @@ -236,7 +236,7 @@ class TempliteTest(CoverageTest): "!", {'nums': [0,1,2], 'abc': ['a', 'b', 'c']}, "@a0b0c0a1b1c1a2b2c2!" - ) + ) def test_whitespace_handling(self): self.try_render( @@ -245,7 +245,7 @@ class TempliteTest(CoverageTest): "{% endfor %}!\n", {'nums': [0, 1, 2], 'abc': ['a', 'b', 'c']}, "@\n a0b0c0\n\n a1b1c1\n\n a2b2c2\n!\n" - ) + ) self.try_render( "@{% for n in nums -%}\n" + " {% for a in abc -%}\n" + @@ -257,7 +257,7 @@ class TempliteTest(CoverageTest): "{% endfor %}!\n", {'nums': [0, 1, 2], 'abc': ['a', 'b', 'c']}, "@a00b00c00\na11b11c11\na22b22c22\n!\n" - ) + ) self.try_render( "@{% for n in nums -%}\n" + " {{n -}}\n" + @@ -265,7 +265,7 @@ class TempliteTest(CoverageTest): "{% endfor %}!\n", {'nums': [0, 1, 2]}, "@0x\n1x\n2x\n!\n" - ) + ) self.try_render(" hello ", {}, " hello ") def test_eat_whitespace(self): @@ -284,7 +284,7 @@ class TempliteTest(CoverageTest): "{% endjoined %}\n", {'nums': [0, 1, 2], 'abc': ['a', 'b', 'c']}, "Hey!\n@XYa0XYb0XYc0XYa1XYb1XYc1XYa2XYb2XYc2!\n" - ) + ) def test_non_ascii(self): self.try_render( diff --git a/tests/test_venv.py b/tests/test_venv.py index 0fe30a49..4bf1eb02 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -212,12 +212,12 @@ class VirtualenvTest(CoverageTest): assert re_lines( r"^Not tracing .*\bexecfile.py': inside --source, but is third-party", debug_out, - ) + ) assert re_lines(r"^Tracing .*\bmyproduct.py", debug_out) assert re_lines( r"^Not tracing .*\bcolorsys.py': falls outside the --source spec", debug_out, - ) + ) out = run_in_venv(coverage_command + " report") assert "myproduct.py" in out @@ -236,15 +236,15 @@ class VirtualenvTest(CoverageTest): r"^Not tracing .*\bexecfile.py': " + "module 'coverage.execfile' falls outside the --source spec", debug_out, - ) + ) assert re_lines( r"^Not tracing .*\bmyproduct.py': module 'myproduct' falls outside the --source spec", debug_out, - ) + ) assert re_lines( r"^Not tracing .*\bcolorsys.py': module 'colorsys' falls outside the --source spec", debug_out, - ) + ) out = run_in_venv(coverage_command + " report") assert "myproduct.py" not in out @@ -300,15 +300,15 @@ class VirtualenvTest(CoverageTest): r"^Not tracing .*\bexecfile.py': " + "module 'coverage.execfile' falls outside the --source spec", debug_out, - ) + ) assert re_lines( r"^Not tracing .*\bmyproduct.py': module 'myproduct' falls outside the --source spec", debug_out, - ) + ) assert re_lines( r"^Not tracing .*\bcolorsys.py': module 'colorsys' falls outside the --source spec", debug_out, - ) + ) out = run_in_venv(coverage_command + " report") @@ -330,6 +330,6 @@ class VirtualenvTest(CoverageTest): out = run_in_venv( coverage_command + " run --source=bug888/app,bug888/plugin bug888/app/testcov/main.py" - ) + ) # When the test fails, the output includes "Already imported a file that will be measured" assert out == "Plugin here\n" diff --git a/tests/test_xml.py b/tests/test_xml.py index 2f332bd3..1e94dfa2 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -152,7 +152,7 @@ class XmlReportTest(XmlTestHelpers, CoverageTest): assert_coverage_warnings( warns, re.compile(r"Couldn't parse '.*innocuous.py'. \(couldnt-parse\)"), - ) + ) self.assert_exists("coverage.xml") def test_filename_format_showing_everything(self): @@ -235,7 +235,7 @@ class XmlReportTest(XmlTestHelpers, CoverageTest): assert_coverage_warnings( warns, "Module not/really was never imported. (module-not-imported)", - ) + ) dom = ElementTree.parse("coverage.xml") self.assert_source(dom, "src/main") @@ -351,7 +351,7 @@ class XmlPackageStructureTest(XmlTestHelpers, CoverageTest): ('package', {'name': "d0.d0"}), ('class', {'filename': "d0/d0/__init__.py", 'name': "__init__.py"}), ('class', {'filename': "d0/d0/f0.py", 'name': "f0.py"}), - ]) + ]) def test_package_depth_1(self): self.make_tree(width=1, depth=4) @@ -372,7 +372,7 @@ class XmlPackageStructureTest(XmlTestHelpers, CoverageTest): ('class', {'filename': "d0/d0/d0/f0.py", 'name': "d0/d0/f0.py"}), ('class', {'filename': "d0/d0/f0.py", 'name': "d0/f0.py"}), ('class', {'filename': "d0/f0.py", 'name': "f0.py"}), - ]) + ]) def test_package_depth_2(self): self.make_tree(width=1, depth=4) @@ -394,7 +394,7 @@ class XmlPackageStructureTest(XmlTestHelpers, CoverageTest): ('class', {'filename': "d0/d0/d0/__init__.py", 'name': "d0/__init__.py"}), ('class', {'filename': "d0/d0/d0/f0.py", 'name': "d0/f0.py"}), ('class', {'filename': "d0/d0/f0.py", 'name': "f0.py"}), - ]) + ]) def test_package_depth_3(self): self.make_tree(width=1, depth=4) @@ -417,7 +417,7 @@ class XmlPackageStructureTest(XmlTestHelpers, CoverageTest): ('package', {'name': "d0.d0.d0"}), ('class', {'filename': "d0/d0/d0/__init__.py", 'name': "__init__.py"}), ('class', {'filename': "d0/d0/d0/f0.py", 'name': "f0.py"}), - ]) + ]) def test_source_prefix(self): # https://github.com/nedbat/coveragepy/issues/465 @@ -429,7 +429,7 @@ class XmlPackageStructureTest(XmlTestHelpers, CoverageTest): self.assert_package_and_class_tags(cov, [ ('package', {'name': "."}), ('class', {'filename': "mod.py", 'name': "mod.py"}), - ]) + ]) dom = ElementTree.parse("coverage.xml") self.assert_source(dom, "src") |