summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.txt2
-rw-r--r--coverage/backward.py2
-rw-r--r--coverage/config.py2
-rw-r--r--coverage/data.py4
-rw-r--r--coverage/debug.py2
-rw-r--r--coverage/html.py2
-rw-r--r--coverage/misc.py4
-rw-r--r--coverage/parser.py10
-rw-r--r--coverage/results.py16
-rw-r--r--coverage/xmlreport.py4
-rw-r--r--igor.py2
-rw-r--r--tests/coveragetest.py10
-rw-r--r--tests/test_farm.py4
-rw-r--r--tests/test_phystokens.py2
-rw-r--r--tests/test_process.py2
-rw-r--r--tests/test_testing.py4
16 files changed, 36 insertions, 36 deletions
diff --git a/TODO.txt b/TODO.txt
index a134bb47..d53dc688 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -14,7 +14,7 @@ Key:
- Remove 2.3, 2.4, 2.5 limitations
+ set, sorted, reversed, rpartition
- - generator expressions
+ + generator expressions
+ decorators
- collections.defaultdict
+ .startswith((,))
diff --git a/coverage/backward.py b/coverage/backward.py
index 124d0253..8237d01b 100644
--- a/coverage/backward.py
+++ b/coverage/backward.py
@@ -123,7 +123,7 @@ else:
def binary_bytes(byte_values):
"""Produce a byte string with the ints from `byte_values`."""
- return "".join([chr(b) for b in byte_values])
+ return "".join(chr(b) for b in byte_values)
def byte_to_int(byte_value):
"""Turn an element of a bytes object into an int."""
diff --git a/coverage/config.py b/coverage/config.py
index 87318ff1..6223afda 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -25,7 +25,7 @@ class HandyConfigParser(configparser.RawConfigParser):
def dollar_replace(m):
"""Called for each $replacement."""
# Only one of the groups will have matched, just get its text.
- word = [w for w in m.groups() if w is not None][0]
+ word = next(w for w in m.groups() if w is not None)
if word == "$":
return "$"
else:
diff --git a/coverage/data.py b/coverage/data.py
index a32e20a4..61b3554f 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -101,13 +101,13 @@ class CoverageData(object):
def line_data(self):
"""Return the map from filenames to lists of line numbers executed."""
return dict(
- [(f, sorted(lmap.keys())) for f, lmap in iitems(self.lines)]
+ (f, sorted(lmap.keys())) for f, lmap in iitems(self.lines)
)
def arc_data(self):
"""Return the map from filenames to lists of line number pairs."""
return dict(
- [(f, sorted(amap.keys())) for f, amap in iitems(self.arcs)]
+ (f, sorted(amap.keys())) for f, amap in iitems(self.arcs)
)
def write_file(self, filename):
diff --git a/coverage/debug.py b/coverage/debug.py
index 104f3b1d..6908383d 100644
--- a/coverage/debug.py
+++ b/coverage/debug.py
@@ -41,7 +41,7 @@ def info_formatter(info):
nicely formatted, ready to print.
"""
- label_len = max([len(l) for l, _d in info])
+ label_len = max(len(l) for l, _d in info)
for label, data in info:
if data == []:
data = "-none-"
diff --git a/coverage/html.py b/coverage/html.py
index 956f070e..e0262998 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -270,7 +270,7 @@ class HtmlReporter(Reporter):
data("index.html"), self.template_globals
)
- self.totals = sum([f['nums'] for f in self.files])
+ self.totals = sum(f['nums'] for f in self.files)
html = index_tmpl.render({
'arcs': self.arcs,
diff --git a/coverage/misc.py b/coverage/misc.py
index 70606287..2a36d5c1 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -57,7 +57,7 @@ def format_lines(statements, lines):
def short_stack():
"""Return a string summarizing the call stack."""
stack = inspect.stack()[:0:-1]
- return "\n".join(["%30s : %s @%d" % (t[3],t[1],t[2]) for t in stack])
+ return "\n".join("%30s : %s @%d" % (t[3],t[1],t[2]) for t in stack)
def expensive(fn):
@@ -86,7 +86,7 @@ def bool_or_none(b):
def join_regex(regexes):
"""Combine a list of regexes into one that matches any of them."""
if len(regexes) > 1:
- return "|".join(["(%s)" % r for r in regexes])
+ return "|".join("(%s)" % r for r in regexes)
elif regexes:
return regexes[0]
else:
diff --git a/coverage/parser.py b/coverage/parser.py
index 0873e7af..010cd73a 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -365,7 +365,7 @@ class ByteParser(object):
"""
children = CodeObjects(self.code)
- return [ByteParser(code=c, text=self.text) for c in children]
+ return (ByteParser(code=c, text=self.text) for c in children)
def _bytes_lines(self):
"""Map byte offsets to line numbers in `code`.
@@ -409,7 +409,7 @@ class ByteParser(object):
def _block_stack_repr(self, block_stack):
"""Get a string version of `block_stack`, for debugging."""
blocks = ", ".join(
- ["(%s, %r)" % (dis.opname[b[0]], b[1]) for b in block_stack]
+ "(%s, %r)" % (dis.opname[b[0]], b[1]) for b in block_stack
)
return "[" + blocks + "]"
@@ -547,9 +547,9 @@ class ByteParser(object):
def validate_chunks(self, chunks):
"""Validate the rule that chunks have a single entrance."""
# starts is the entrances to the chunks
- starts = set([ch.byte for ch in chunks])
+ starts = set(ch.byte for ch in chunks)
for ch in chunks:
- assert all([(ex in starts or ex < 0) for ex in ch.exits])
+ assert all((ex in starts or ex < 0) for ex in ch.exits)
def _arcs(self):
"""Find the executable arcs in the code.
@@ -562,7 +562,7 @@ class ByteParser(object):
chunks = self._split_into_chunks()
# A map from byte offsets to chunks jumped into.
- byte_chunks = dict([(c.byte, c) for c in chunks])
+ byte_chunks = dict((c.byte, c) for c in chunks)
# There's always an entrance at the first chunk.
yield (-1, byte_chunks[0].line)
diff --git a/coverage/results.py b/coverage/results.py
index 7ffd66bf..bfd9e52e 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -36,9 +36,9 @@ class Analysis(object):
n_branches = self.total_branches()
mba = self.missing_branch_arcs()
n_partial_branches = sum(
- [len(v) for k,v in iitems(mba) if k not in self.missing]
+ len(v) for k,v in iitems(mba) if k not in self.missing
)
- n_missing_branches = sum([len(v) for k,v in iitems(mba)])
+ n_missing_branches = sum(len(v) for k,v in iitems(mba))
else:
n_branches = n_partial_branches = n_missing_branches = 0
self.no_branch = set()
@@ -112,18 +112,18 @@ class Analysis(object):
"""Returns a sorted list of the arcs actually executed in the code."""
executed = self.coverage.data.executed_arcs(self.filename)
m2fl = self.parser.first_line
- executed = [(m2fl(l1), m2fl(l2)) for (l1,l2) in executed]
+ executed = ((m2fl(l1), m2fl(l2)) for (l1,l2) in executed)
return sorted(executed)
def arcs_missing(self):
"""Returns a sorted list of the arcs in the code not executed."""
possible = self.arc_possibilities()
executed = self.arcs_executed()
- missing = [
+ missing = (
p for p in possible
if p not in executed
and p[0] not in self.no_branch
- ]
+ )
return sorted(missing)
def arcs_unpredicted(self):
@@ -133,11 +133,11 @@ class Analysis(object):
# Exclude arcs here which connect a line to itself. They can occur
# in executed data in some cases. This is where they can cause
# trouble, and here is where it's the least burden to remove them.
- unpredicted = [
+ unpredicted = (
e for e in executed
if e not in possible
and e[0] != e[1]
- ]
+ )
return sorted(unpredicted)
def branch_lines(self):
@@ -148,7 +148,7 @@ class Analysis(object):
def total_branches(self):
"""How many total branches are there?"""
exit_counts = self.parser.exit_counts()
- return sum([count for count in exit_counts.values() if count > 1])
+ return sum(count for count in exit_counts.values() if count > 1)
def missing_branch_arcs(self):
"""Return arcs that weren't executed from branch lines.
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py
index 1abfdefb..d4b102fa 100644
--- a/coverage/xmlreport.py
+++ b/coverage/xmlreport.py
@@ -137,8 +137,8 @@ class XmlReporter(Reporter):
class_hits = class_lines - len(analysis.missing)
if self.arcs:
- class_branches = sum([t for t,k in branch_stats.values()])
- missing_branches = sum([t-k for t,k in branch_stats.values()])
+ class_branches = sum(t for t, k in branch_stats.values())
+ missing_branches = sum(t - k for t, k in branch_stats.values())
class_br_hits = class_branches - missing_branches
else:
class_branches = 0.0
diff --git a/igor.py b/igor.py
index 12ec6c8f..9f33f153 100644
--- a/igor.py
+++ b/igor.py
@@ -216,7 +216,7 @@ def print_banner(label):
if '__pypy__' in sys.builtin_module_names:
pypy_version = sys.pypy_version_info # pylint: disable=E1101
- version += " (pypy %s)" % ".".join([str(v) for v in pypy_version])
+ version += " (pypy %s)" % ".".join(str(v) for v in pypy_version)
print('=== %s %s %s (%s) ===' % (impl, version, label, sys.executable))
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index cb2957da..d4d82f12 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -266,10 +266,10 @@ class CoverageTest(TestCase):
# Map chars to numbers for arcz_to_arcs
_arcz_map = {'.': -1}
- _arcz_map.update(dict([(c, ord(c)-ord('0')) for c in '123456789']))
+ _arcz_map.update(dict((c, ord(c)-ord('0')) for c in '123456789'))
_arcz_map.update(dict(
- [(c, 10+ord(c)-ord('A')) for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']
- ))
+ (c, 10+ord(c)-ord('A')) for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ ))
def arcz_to_arcs(self, arcz):
"""Convert a compact textual representation of arcs to a list of pairs.
@@ -305,8 +305,8 @@ class CoverageTest(TestCase):
def assertEqualArcs(self, a1, a2, msg=None):
"""Assert that the arc lists `a1` and `a2` are equal."""
# Make them into multi-line strings so we can see what's going wrong.
- s1 = "\n".join([repr(a) for a in a1]) + "\n"
- s2 = "\n".join([repr(a) for a in a2]) + "\n"
+ s1 = "\n".join(repr(a) for a in a1) + "\n"
+ s2 = "\n".join(repr(a) for a in a2) + "\n"
self.assertMultiLineEqual(s1, s2, msg)
def check_coverage(self, text, lines=None, missing="", report="",
diff --git a/tests/test_farm.py b/tests/test_farm.py
index fee28063..c86983e5 100644
--- a/tests/test_farm.py
+++ b/tests/test_farm.py
@@ -78,10 +78,10 @@ class FarmTestCase(object):
copy run runfunc compare contains doesnt_contain clean skip
""".split()
if self.clean_only:
- glo = dict([(fn, self.noop) for fn in fns])
+ glo = dict((fn, self.noop) for fn in fns)
glo['clean'] = self.clean
else:
- glo = dict([(fn, getattr(self, fn)) for fn in fns])
+ glo = dict((fn, getattr(self, fn)) for fn in fns)
if self.dont_clean: # pragma: not covered
glo['clean'] = self.noop
diff --git a/tests/test_phystokens.py b/tests/test_phystokens.py
index 76e59f3b..9ff053c4 100644
--- a/tests/test_phystokens.py
+++ b/tests/test_phystokens.py
@@ -29,7 +29,7 @@ class PhysTokensTest(CoverageTest):
"""Tokenize `source`, then put it back together, should be the same."""
tokenized = ""
for line in source_token_lines(source):
- text = "".join([t for _,t in line])
+ text = "".join(t for _, t in line)
tokenized += text + "\n"
# source_token_lines doesn't preserve trailing spaces, so trim all that
# before comparing.
diff --git a/tests/test_process.py b/tests/test_process.py
index d1107e32..4453fc57 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -270,7 +270,7 @@ class ProcessTest(CoverageTest):
if '__pypy__' in sys.builtin_module_names:
# Pypy has an extra frame in the traceback for some reason
lines2 = out2.splitlines()
- out2 = "".join([l+"\n" for l in lines2 if "toplevel" not in l])
+ out2 = "".join(l+"\n" for l in lines2 if "toplevel" not in l)
self.assertMultiLineEqual(out, out2)
# But also make sure that the output is what we expect.
diff --git a/tests/test_testing.py b/tests/test_testing.py
index c6d51ba5..64dca617 100644
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -183,10 +183,10 @@ class CoverageTestTest(CoverageTest):
# Try it with a "coverage debug sys" command.
out = self.run_command("coverage debug sys").splitlines()
# "environment: COV_FOOBAR = XYZZY" or "COV_FOOBAR = XYZZY"
- executable = [l for l in out if "executable:" in l][0]
+ executable = next(l for l in out if "executable:" in l)
executable = executable.split(":", 1)[1].strip()
self.assertTrue(same_python_executable(executable, sys.executable))
- environ = [l for l in out if "COV_FOOBAR" in l][0]
+ environ = next(l for l in out if "COV_FOOBAR" in l)
_, _, environ = environ.rpartition(":")
self.assertEqual(environ.strip(), "COV_FOOBAR = XYZZY")