From 420c01394a31415d7a7cbb80be196bcfca48482c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 1 May 2022 08:16:06 -0400 Subject: [PATCH] style: parens should indent the same as their opening line --- ci/comment_on_fixes.py | 2 +- coverage/cmdline.py | 24 ++++++++++------------ coverage/config.py | 2 +- coverage/control.py | 12 +++++------ coverage/debug.py | 2 +- coverage/html.py | 6 +++--- coverage/inorout.py | 2 +- coverage/jsonreport.py | 2 +- coverage/misc.py | 2 +- coverage/parser.py | 6 +++--- coverage/phystokens.py | 2 +- coverage/python.py | 4 ++-- coverage/results.py | 4 ++-- coverage/sqldata.py | 6 +++--- coverage/summary.py | 4 ++-- coverage/xmlreport.py | 4 ++-- doc/conf.py | 2 +- lab/goals.py | 2 +- lab/hack_pyc.py | 2 +- lab/parser.py | 8 ++++---- lab/run_trace.py | 2 +- tests/conftest.py | 4 ++-- tests/helpers.py | 4 ++-- tests/test_annotate.py | 2 +- tests/test_api.py | 4 ++-- tests/test_arcs.py | 32 ++++++++++++++--------------- tests/test_cmdline.py | 12 +++++------ tests/test_coverage.py | 14 ++++++------- tests/test_data.py | 2 +- tests/test_files.py | 4 ++-- tests/test_html.py | 8 ++++---- tests/test_json.py | 18 ++++++++--------- tests/test_numbits.py | 2 +- tests/test_oddball.py | 12 +++++------ tests/test_parser.py | 10 ++++----- tests/test_plugins.py | 10 ++++----- tests/test_process.py | 4 ++-- tests/test_results.py | 6 +++--- tests/test_setup.py | 2 +- tests/test_summary.py | 2 +- tests/test_templite.py | 46 +++++++++++++++++++++--------------------- tests/test_venv.py | 18 ++++++++--------- tests/test_xml.py | 14 ++++++------- 43 files changed, 164 insertions(+), 166 deletions(-) diff --git a/ci/comment_on_fixes.py b/ci/comment_on_fixes.py index f36cba939..b0f469b15 100644 --- a/ci/comment_on_fixes.py +++ b/ci/comment_on_fixes.py @@ -13,7 +13,7 @@ comment = ( f"This is now released as part of [coverage {version}]" + f"(https://pypi.org/project/coverage/{version})." - ) +) print(f"Comment will be: {comment}") owner = "nedbat" diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 0c44378a9..dbf66e0a8 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -232,9 +232,7 @@ class CoverageOptionParser(optparse.OptionParser): """ def __init__(self, *args, **kwargs): - super().__init__( - add_help_option=False, *args, **kwargs - ) + super().__init__(add_help_option=False, *args, **kwargs) self.set_defaults( # Keep these arguments alphabetized by their names. action=None, @@ -267,7 +265,7 @@ def __init__(self, *args, **kwargs): timid=None, title=None, version=None, - ) + ) self.disable_interspersed_args() @@ -352,7 +350,7 @@ def get_prog_name(self): Opts.debug, Opts.help, Opts.rcfile, - ] +] COMMANDS = { 'annotate': CmdOptionParser( @@ -473,7 +471,7 @@ def get_prog_name(self): Opts.output_lcov, Opts.omit, Opts.quiet, - ] + GLOBAL_ARGS, + ] + GLOBAL_ARGS, usage="[options] [modules]", description="Generate an LCOV report of coverage results.", ), @@ -648,7 +646,7 @@ def command_line(self, argv): check_preimported=True, context=options.context, messages=not options.quiet, - ) + ) if options.action == "debug": return self.do_debug(args) @@ -675,7 +673,7 @@ def command_line(self, argv): omit=omit, include=include, contexts=contexts, - ) + ) # We need to be able to import from the current directory, because # plugins may try to, for example, to read Django settings. @@ -692,7 +690,7 @@ def command_line(self, argv): skip_empty=options.skip_empty, sort=options.sort, **report_args - ) + ) elif options.action == "annotate": self.coverage.annotate(directory=options.directory, **report_args) elif options.action == "html": @@ -704,25 +702,25 @@ def command_line(self, argv): show_contexts=options.show_contexts, title=options.title, **report_args - ) + ) elif options.action == "xml": total = self.coverage.xml_report( outfile=options.outfile, skip_empty=options.skip_empty, **report_args - ) + ) elif options.action == "json": total = self.coverage.json_report( outfile=options.outfile, pretty_print=options.pretty_print, show_contexts=options.show_contexts, **report_args - ) + ) elif options.action == "lcov": total = self.coverage.lcov_report( outfile=options.outfile, **report_args - ) + ) else: # There are no other possible actions. raise AssertionError diff --git a/coverage/config.py b/coverage/config.py index fbfb59f4f..1571c0176 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -499,7 +499,7 @@ def debug_info(self): """Make a list of (name, value) pairs for writing debug info.""" return human_sorted_items( (k, v) for k, v in self.__dict__.items() if not k.startswith("_") - ) + ) def config_files_to_try(config_file): diff --git a/coverage/control.py b/coverage/control.py index 910cfb083..6387d0dd3 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -250,7 +250,7 @@ def __init__( source=source, source_pkgs=source_pkgs, run_omit=omit, run_include=include, debug=debug, report_omit=omit, report_include=include, concurrency=concurrency, context=context, - ) + ) # If we have sub-process measurement happening automatically, then we # want any explicit creation of a Coverage object to mean, this process @@ -489,7 +489,7 @@ def _init_for_start(self): branch=self.config.branch, warn=self._warn, concurrency=concurrency, - ) + ) suffix = self._data_suffix_specified if suffix: @@ -515,10 +515,10 @@ def _init_for_start(self): ", ".join( plugin._coverage_plugin_name for plugin in self._plugins.file_tracers - ), + ), self._collector.tracer_name(), - ) ) + ) for plugin in self._plugins.file_tracers: plugin._coverage_enabled = False @@ -835,7 +835,7 @@ def analysis2(self, morf): sorted(analysis.excluded), sorted(analysis.missing), analysis.missing_formatted(), - ) + ) def _analyze(self, it): """Analyze a single morf or code unit. @@ -1146,7 +1146,7 @@ def plugin_info(plugins): ) )), ('command_line', " ".join(getattr(sys, 'argv', ['-none-']))), - ] + ] if self._inorout: info.extend(self._inorout.sys_info()) diff --git a/coverage/debug.py b/coverage/debug.py index 8c5e3839f..7ec3ae42b 100644 --- a/coverage/debug.py +++ b/coverage/debug.py @@ -211,7 +211,7 @@ def __repr__(self): klass=self.__class__.__name__, id=id(self), attrs=" ".join(f"{k}={v!r}" for k, v in show_attrs), - ) + ) def simplify(v): # pragma: debugging diff --git a/coverage/html.py b/coverage/html.py index 342d2ad1c..e18a30a11 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -188,7 +188,7 @@ def __init__(self, cov): 'mis': 'mis show_mis', 'par': 'par run show_par', 'run': 'run', - } + }, } self.pyfile_html_source = read_data("pyfile.html") self.source_tmpl = Templite(self.pyfile_html_source, self.template_globals) @@ -292,7 +292,7 @@ def html_file(self, fr, analysis): ldata.annotate = ",   ".join( f"{ldata.number} ↛ {d}" for d in ldata.short_annotations - ) + ) else: ldata.annotate = None @@ -306,7 +306,7 @@ def html_file(self, fr, analysis): ", ".join( f"{num:d}) {ann_long}" for num, ann_long in enumerate(longs, start=1) - ), + ), ) else: ldata.annotate_long = None diff --git a/coverage/inorout.py b/coverage/inorout.py index 25943cb14..ec89d1b49 100644 --- a/coverage/inorout.py +++ b/coverage/inorout.py @@ -591,7 +591,7 @@ def sys_info(self): 'source_match', 'source_pkgs_match', 'include_match', 'omit_match', 'cover_match', 'pylib_match', 'third_match', - ] + ] for matcher_name in matcher_names: matcher = getattr(self, matcher_name) diff --git a/coverage/jsonreport.py b/coverage/jsonreport.py index 75ba755d9..43edc4520 100644 --- a/coverage/jsonreport.py +++ b/coverage/jsonreport.py @@ -70,7 +70,7 @@ def report(self, morfs, outfile=None): json.dump( self.report_data, outfile, - indent=4 if self.config.json_pretty_print else None + indent=(4 if self.config.json_pretty_print else None), ) return self.total.n_statements and self.total.pc_covered diff --git a/coverage/misc.py b/coverage/misc.py index aaf1bcf77..777cdc439 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -272,7 +272,7 @@ def _needs_to_implement(that, func_name): raise NotImplementedError( f"{thing} {name!r} needs to implement {func_name}()" - ) + ) class DefaultValue: diff --git a/coverage/parser.py b/coverage/parser.py index dc7c74040..60b6dc35a 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -1231,15 +1231,15 @@ def _handle__With(self, node): if with_block.break_from: self.process_break_exits( self._combine_finally_starts(with_block.break_from, with_exit) - ) + ) if with_block.continue_from: self.process_continue_exits( self._combine_finally_starts(with_block.continue_from, with_exit) - ) + ) if with_block.return_from: self.process_return_exits( self._combine_finally_starts(with_block.return_from, with_exit) - ) + ) return exits _handle__AsyncWith = _handle__With diff --git a/coverage/phystokens.py b/coverage/phystokens.py index b6b08d002..7184f1604 100644 --- a/coverage/phystokens.py +++ b/coverage/phystokens.py @@ -60,7 +60,7 @@ def phys_tokens(toks): 99999, "\\\n", (slineno, ccol), (slineno, ccol+2), last_line - ) + ) last_line = ltext if ttype not in (tokenize.NEWLINE, tokenize.NL): last_ttext = ttext diff --git a/coverage/python.py b/coverage/python.py index 78c3e716e..da43e6e8b 100644 --- a/coverage/python.py +++ b/coverage/python.py @@ -202,8 +202,8 @@ def translate_arcs(self, arcs): def no_branch_lines(self): no_branch = self.parser.lines_matching( join_regex(self.coverage.config.partial_list), - join_regex(self.coverage.config.partial_always_list) - ) + join_regex(self.coverage.config.partial_always_list), + ) return no_branch @expensive diff --git a/coverage/results.py b/coverage/results.py index 9675bff99..79439fd9b 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -271,10 +271,10 @@ def __add__(self, other): nums.n_branches = self.n_branches + other.n_branches nums.n_partial_branches = ( self.n_partial_branches + other.n_partial_branches - ) + ) nums.n_missing_branches = ( self.n_missing_branches + other.n_missing_branches - ) + ) return nums def __radd__(self, other): diff --git a/coverage/sqldata.py b/coverage/sqldata.py index b3157a8a7..aa4002a70 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -643,7 +643,7 @@ def update(self, other_data, aliases=None): "from line_bits " + "inner join file on file.id = line_bits.file_id " + "inner join context on context.id = line_bits.context_id" - ) + ) lines = {(files[path], context): numbits for (path, context, numbits) in cur} cur.close() @@ -720,7 +720,7 @@ def update(self, other_data, aliases=None): "from line_bits " + "inner join file on file.id = line_bits.file_id " + "inner join context on context.id = line_bits.context_id" - ) + ) for path, context, numbits in cur: key = (aliases.map(path), context) if key in lines: @@ -977,7 +977,7 @@ def contexts_by_lineno(self, filename): "select l.numbits, c.context from line_bits l, context c " + "where l.context_id = c.id " + "and file_id = ?" - ) + ) data = [file_id] if self._query_context_ids is not None: ids_array = ", ".join("?" * len(self._query_context_ids)) diff --git a/coverage/summary.py b/coverage/summary.py index 467c601d2..861fbc536 100644 --- a/coverage/summary.py +++ b/coverage/summary.py @@ -127,11 +127,11 @@ def report(self, morfs, outfile=None): if self.config.skip_covered and self.skipped_count: self.writeout( fmt_skip_covered % (self.skipped_count, 's' if self.skipped_count > 1 else '') - ) + ) if self.config.skip_empty and self.empty_count: self.writeout( fmt_skip_empty % (self.empty_count, 's' if self.empty_count > 1 else '') - ) + ) return self.total.n_statements and self.total.pc_covered diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index ebc85de4b..2c34cb546 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -68,7 +68,7 @@ def report(self, morfs, outfile=None): xcoverage.setAttribute("timestamp", str(int(time.time()*1000))) xcoverage.appendChild(self.xml_out.createComment( f" Generated by coverage.py: {__url__} " - )) + )) xcoverage.appendChild(self.xml_out.createComment(f" Based on {DTD_URL} ")) # Call xml_file for each file in the data. @@ -193,7 +193,7 @@ def xml_file(self, fr, analysis, has_arcs): xline.setAttribute( "condition-coverage", "%d%% (%d/%d)" % (100*taken//total, taken, total) - ) + ) if line in missing_branch_arcs: annlines = ["exit" if b < 0 else str(b) for b in missing_branch_arcs[line]] xline.setAttribute("missing-branches", ",".join(annlines)) diff --git a/doc/conf.py b/doc/conf.py index a5c1d02b1..a8387b132 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -119,7 +119,7 @@ intersphinx_mapping = { 'python': ('https://docs.python.org/3', None), - } +} # -- Options for HTML output --------------------------------------------------- diff --git a/lab/goals.py b/lab/goals.py index 8d8acdc62..4bda0f0f5 100644 --- a/lab/goals.py +++ b/lab/goals.py @@ -40,7 +40,7 @@ def total_for_files(data, files): n_branches=sel_summ.get("num_branches", 0), n_partial_branches=sel_summ.get("num_partial_branches", 0), n_missing_branches=sel_summ.get("missing_branches", 0), - ) + ) return total diff --git a/lab/hack_pyc.py b/lab/hack_pyc.py index d63da8fa3..60b8459b5 100644 --- a/lab/hack_pyc.py +++ b/lab/hack_pyc.py @@ -71,7 +71,7 @@ def hack_line_numbers(code): code.co_argcount, code.co_nlocals, code.co_stacksize, code.co_flags, code.co_code, tuple(new_consts), code.co_names, code.co_varnames, code.co_filename, code.co_name, new_firstlineno, new_lnotab - ) + ) return new_code diff --git a/lab/parser.py b/lab/parser.py index 50b435644..43f3da52d 100644 --- a/lab/parser.py +++ b/lab/parser.py @@ -28,19 +28,19 @@ def main(self, args): parser.add_option( "-d", action="store_true", dest="dis", help="Disassemble" - ) + ) parser.add_option( "-R", action="store_true", dest="recursive", help="Recurse to find source files" - ) + ) parser.add_option( "-s", action="store_true", dest="source", help="Show analyzed source" - ) + ) parser.add_option( "-t", action="store_true", dest="tokens", help="Show tokens" - ) + ) options, args = parser.parse_args() if options.recursive: diff --git a/lab/run_trace.py b/lab/run_trace.py index c0e475937..54e6a53f0 100644 --- a/lab/run_trace.py +++ b/lab/run_trace.py @@ -20,7 +20,7 @@ def trace(frame, event, arg): os.path.basename(frame.f_code.co_filename), frame.f_lineno, frame.f_lasti, - )) + )) if event == 'call': nest += 1 diff --git a/tests/conftest.py b/tests/conftest.py index 39f39e250..03b51b2ce 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 890bd7c5f..3d1778241 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 @@ def wrapper(self, filename, *args, **kwargs): """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 09893143b..e2d49f251 100644 --- a/tests/test_annotate.py +++ b/tests/test_annotate.py @@ -128,5 +128,5 @@ def f(x): "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 bc2d05f62..63bb9abce 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -540,7 +540,7 @@ def test_warnings(self): "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 @@ def test_combine_no_suffix_multiprocessing(self): 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 10157a77f..c2ae7847e 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -135,7 +135,7 @@ def foo(): 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 @@ def foo(): 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 @@ def foo(x): """, 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 @@ def example(): example() """, arcz=arcz, - ) + ) def test_with_return(self): arcz = ".1 .2 23 34 4. 16 6." @@ -210,7 +210,7 @@ def example(): example() """, arcz=arcz, - ) + ) def test_bug_146(self): # https://github.com/nedbat/coveragepy/issues/146 @@ -225,7 +225,7 @@ def test_bug_146(self): print(5) """, arcz=arcz, - ) + ) def test_nested_with_return(self): arcz = ".1 .2 23 34 45 56 6. 18 8." @@ -242,7 +242,7 @@ def example(x): example(8) """, arcz=arcz, - ) + ) def test_break_through_with(self): arcz = ".1 12 23 34 45 15 5." @@ -257,7 +257,7 @@ def test_break_through_with(self): """, arcz=arcz, arcz_missing="15", - ) + ) def test_continue_through_with(self): arcz = ".1 12 23 34 41 15 5." @@ -271,7 +271,7 @@ def test_continue_through_with(self): print(5) """, arcz=arcz, - ) + ) @pytest.mark.xfail( (3, 11) <= env.PYVERSION <= (3, 11, 0, 'alpha', 2, 0), @@ -302,7 +302,7 @@ def f(x): 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 @@ def f(x): """, 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 @@ def test_while_1(self): 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 @@ def test_bug_496_continue_in_constant_while(self): break """, arcz=arcz - ) + ) def test_for_if_else_for(self): self.check_coverage("""\ @@ -519,7 +519,7 @@ def branches_3(l): ".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 @@ def forelse(seq): 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 @@ def test_unused_lambdas_are_confusing_bug_90(self): 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 a088ab8af..c147b527a 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -107,7 +107,7 @@ def mock_command_line(self, args, options=None): 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 @@ def test_run_from_config(self): cov.save() """, options=options, - ) + ) def test_run_module_from_config(self): self.cmd_executes("run", """\ @@ -810,7 +810,7 @@ def test_run_module_from_config(self): 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 @@ def test_run_from_config_but_empty(self): """, ret=ERR, options={"run:command_line": ""}, - ) + ) def test_run_dashm_only(self): self.cmd_executes("run -m", """\ @@ -827,14 +827,14 @@ def test_run_dashm_only(self): 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 fc4263de9..9164db0fb 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -22,14 +22,14 @@ def test_successful_coverage(self): 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 @@ def test_successful_coverage(self): """, [1,2,3], missing="3", - ) + ) # You can specify a list of possible missing lines. self.check_coverage("""\ a = 1 @@ -47,7 +47,7 @@ def test_successful_coverage(self): """, [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 @@ def test_exceptions_really_fail(self): a = 1 assert a == 99, "This is bad" """ - ) + ) # Other exceptions too. with pytest.raises(ZeroDivisionError, match="division"): self.check_coverage("""\ @@ -104,7 +104,7 @@ def test_exceptions_really_fail(self): assert a == 1, "This is good" a/0 """ - ) + ) class BasicCoverageTest(CoverageTest): @@ -1256,7 +1256,7 @@ def test_default(self): 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 f9928467f..f8bff2eb0 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -888,6 +888,6 @@ def test_misfed_serialization(self): 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 0780fdb3c..5588c373d 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -170,7 +170,7 @@ def test_tree_matcher(self): 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 @@ def test_find_python_files(self): "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 797fee1d9..b1951cdbd 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -363,7 +363,7 @@ def test_dotpy_not_python_ignored(self): 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 @@ def test_other(self): gold_path("html/other"), "out/other", extra_scrubs=[ (r'href="d_[0-9a-z]{16}_', 'href="_TEST_TMPDIR_othersrc_'), - ], - ) + ], + ) contains( 'out/other/index.html', 'here.py', @@ -1096,7 +1096,7 @@ def test_two(): assert b == (14-4) helper( 16 - ) + ) test_one() x = 20 diff --git a/tests/test_json.py b/tests/test_json.py index b750a6664..63713af8c 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -57,8 +57,8 @@ def test_branch_coverage(self): 'missing_branches': 1, 'percent_covered': 60.0, 'percent_covered_display': '60', - } - } + }, + }, }, 'totals': { 'missing_lines': 1, @@ -71,7 +71,7 @@ def test_branch_coverage(self): 'percent_covered_display': '60', 'covered_branches': 1, 'missing_branches': 1, - } + }, } self._assert_expected_json_report(cov, expected_result) @@ -95,8 +95,8 @@ def test_simple_line_coverage(self): 'num_statements': 3, 'percent_covered': 66.66666666666667, 'percent_covered_display': '67', - } - } + }, + }, }, 'totals': { 'excluded_lines': 0, @@ -105,7 +105,7 @@ def test_simple_line_coverage(self): 'num_statements': 3, 'percent_covered': 66.66666666666667, 'percent_covered_display': '67', - } + }, } self._assert_expected_json_report(cov, expected_result) @@ -148,8 +148,8 @@ def run_context_test(self, relative_files): 'num_statements': 3, 'percent_covered': 66.66666666666667, 'percent_covered_display': '66.67', - } - } + }, + }, }, 'totals': { 'excluded_lines': 0, @@ -158,7 +158,7 @@ def run_context_test(self, relative_files): '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 359097b6a..39cb93f66 100644 --- a/tests/test_numbits.py +++ b/tests/test_numbits.py @@ -13,7 +13,7 @@ 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 703e81878..15dae128a 100644 --- a/tests/test_oddball.py +++ b/tests/test_oddball.py @@ -94,7 +94,7 @@ def recur(n): 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 @@ def doit(calls): '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 29c93035f..cc5d6ba0d 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -44,7 +44,7 @@ class Bar: """) 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 @@ def test_try_except(self): """) 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 Bar: """) 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 @@ def test_match_case_with_default(self): """) 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 edf849f66..b4239700d 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -196,7 +196,7 @@ def coverage_init(reg, options): 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 @@ def coverage_init(reg, options): "-- 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 @@ def coverage_init(reg, options): 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 @@ def test_plugin2_with_text_report(self): '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 @@ def coverage_init(reg, options): '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 eac3ddda5..c473cf9a7 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -826,7 +826,7 @@ def test_coverage_custom_script(self): 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 @@ def test_report_99p9_is_not_ok(self): "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 4138ffd49..41f3dc40a 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 aa65af788..5468e3bf1 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -23,7 +23,7 @@ def setUp(self): 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 7e8f29192..4bce80f6d 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -597,7 +597,7 @@ def test_dotpy_not_python_ignored(self): 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 0f86690be..d2e98479b 100644 --- a/tests/test_templite.py +++ b/tests/test_templite.py @@ -71,7 +71,7 @@ def test_pipes(self): '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 @@ def test_reusability(self): 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 @@ def test_loops(self): "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 @@ def rev(l): "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 @@ def test_multiple_loops(self): "{% 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 @@ def getit(self): "!", { '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 @@ def test_nested_loops(self): "!", {'nums': [0,1,2], 'abc': ['a', 'b', 'c']}, "@a0b0c0a1b1c1a2b2c2!" - ) + ) def test_whitespace_handling(self): self.try_render( @@ -245,7 +245,7 @@ def test_whitespace_handling(self): "{% 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 @@ def test_whitespace_handling(self): "{% 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 @@ def test_whitespace_handling(self): "{% 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 @@ def test_eat_whitespace(self): "{% 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 0fe30a497..4bf1eb029 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -212,12 +212,12 @@ def test_third_party_venv_isnt_measured(self, coverage_command): 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 @@ def test_us_in_venv_isnt_measured(self, coverage_command): 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 @@ def test_installed_namespace_packages(self, coverage_command): 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 @@ def test_bug_888(self, coverage_command): 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 2f332bd33..1e94dfa2e 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -152,7 +152,7 @@ def test_no_source(self): 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 @@ def test_deep_source(self): 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 @@ def test_package_names(self): ('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 @@ def test_package_depth_1(self): ('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 @@ def test_package_depth_2(self): ('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 @@ def test_package_depth_3(self): ('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 @@ def test_source_prefix(self): 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")