summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/config.py6
-rw-r--r--coverage/control.py57
-rw-r--r--coverage/misc.py4
-rw-r--r--coverage/results.py11
-rw-r--r--test/coveragetest.py7
-rw-r--r--test/farm/html/gold_partial/index.html82
-rw-r--r--test/farm/html/gold_partial/partial.html121
-rw-r--r--test/farm/html/run_partial.py27
-rw-r--r--test/farm/html/src/partial.py19
-rw-r--r--test/test_api.py35
-rw-r--r--test/test_arcs.py38
-rw-r--r--test/test_coverage.py58
12 files changed, 400 insertions, 65 deletions
diff --git a/coverage/config.py b/coverage/config.py
index 4507bc22..f842964d 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -17,10 +17,8 @@ DEFAULT_PARTIAL = [
# These are any Python branching constructs that can't actually execute all
# their branches.
DEFAULT_PARTIAL_ALWAYS = [
- 'while True:',
- 'while 1:',
- 'if 0:',
- 'if 1:',
+ 'while (True|1|False|0):',
+ 'if (True|1|False|0):',
]
diff --git a/coverage/control.py b/coverage/control.py
index b71887f7..2d964395 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -109,8 +109,10 @@ class coverage(object):
self.auto_data = auto_data
self.atexit_registered = False
- self.exclude_re = ""
- self._compile_exclude()
+ # _exclude_re is a dict mapping exclusion list names to compiled
+ # regexes.
+ self._exclude_re = {}
+ self._exclude_regex_stale()
self.file_locator = FileLocator()
@@ -395,30 +397,49 @@ class coverage(object):
self.collector.reset()
self.data.erase()
- def clear_exclude(self):
+ def clear_exclude(self, which='exclude'):
"""Clear the exclude list."""
- self.config.exclude_list = []
- self.exclude_re = ""
+ setattr(self.config, which + "_list", [])
+ self._exclude_regex_stale()
- def exclude(self, regex):
+ def exclude(self, regex, which='exclude'):
"""Exclude source lines from execution consideration.
- `regex` is a regular expression. Lines matching this expression are
- not considered executable when reporting code coverage. A list of
- regexes is maintained; this function adds a new regex to the list.
- Matching any of the regexes excludes a source line.
+ A number of lists of regular expressions are maintained. Each list
+ selects lines that are treated differently during reporting.
+
+ `which` determines which list is modified. The "exclude" list selects
+ lines that are not considered executable at all. The "partial" list
+ indicates lines with branches that are not taken.
+
+ `regex` is a regular expression. The regex is added to the specified
+ list. If any of the regexes in the list is found in a line, the line
+ is marked for special treatment during reporting.
"""
- self.config.exclude_list.append(regex)
- self._compile_exclude()
+ excl_list = getattr(self.config, which + "_list")
+ excl_list.append(regex)
+ self._exclude_regex_stale()
+
+ def _exclude_regex_stale(self):
+ """Drop all the compiled exclusion regexes, a list was modified."""
+ self._exclude_re.clear()
- def _compile_exclude(self):
- """Build the internal usable form of the exclude list."""
- self.exclude_re = join_regex(self.config.exclude_list)
+ def _exclude_regex(self, which):
+ """Return a compiled regex for the given exclusion list."""
+ if which not in self._exclude_re:
+ excl_list = getattr(self.config, which + "_list")
+ self._exclude_re[which] = join_regex(excl_list)
+ return self._exclude_re[which]
- def get_exclude_list(self):
- """Return the list of excluded regex patterns."""
- return self.config.exclude_list
+ def get_exclude_list(self, which='exclude'):
+ """Return a list of excluded regex patterns.
+
+ `which` indicates which list is desired. See `exclude` for the lists
+ that are available, and their meaning.
+
+ """
+ return getattr(self.config, which + "_list")
def save(self):
"""Save the collected coverage data to the data file."""
diff --git a/coverage/misc.py b/coverage/misc.py
index ec0d0ff7..fd9be857 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -77,8 +77,10 @@ def join_regex(regexes):
"""Combine a list of regexes into one that matches any of them."""
if len(regexes) > 1:
return "(" + ")|(".join(regexes) + ")"
- else:
+ elif regexes:
return regexes[0]
+ else:
+ return ""
class Hasher(object):
diff --git a/coverage/results.py b/coverage/results.py
index 7b032f18..adfb8f42 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -25,7 +25,7 @@ class Analysis(object):
self.parser = CodeParser(
text=source, filename=self.filename,
- exclude=self.coverage.exclude_re
+ exclude=self.coverage._exclude_regex('exclude')
)
self.statements, self.excluded = self.parser.parse_source()
@@ -70,8 +70,6 @@ class Analysis(object):
def arc_possibilities(self):
"""Returns a sorted list of the arcs in the code."""
arcs = self.parser.arcs()
- if self.no_branch:
- arcs = [(a,b) for (a,b) in arcs if a not in self.no_branch]
return arcs
def arcs_executed(self):
@@ -85,7 +83,11 @@ class Analysis(object):
"""Returns a sorted list of the arcs in the code not executed."""
possible = self.arc_possibilities()
executed = self.arcs_executed()
- missing = [p for p in possible if p not in executed]
+ 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):
@@ -99,7 +101,6 @@ class Analysis(object):
e for e in executed
if e not in possible
and e[0] != e[1]
- and e[0] not in self.no_branch
]
return sorted(unpredicted)
diff --git a/test/coveragetest.py b/test/coveragetest.py
index 93cffa86..c2276595 100644
--- a/test/coveragetest.py
+++ b/test/coveragetest.py
@@ -251,8 +251,9 @@ class CoverageTest(TestCase):
s2 = "\n".join([repr(a) for a in a2]) + "\n"
self.assertMultiLineEqual(s1, s2, msg)
- def check_coverage(self, text, lines=None, missing="", excludes=None,
- report="", arcz=None, arcz_missing="", arcz_unpredicted=""):
+ def check_coverage(self, text, lines=None, missing="", report="",
+ excludes=None, partials="",
+ arcz=None, arcz_missing="", arcz_unpredicted=""):
"""Check the coverage measurement of `text`.
The source `text` is run and measured. `lines` are the line numbers
@@ -285,6 +286,8 @@ class CoverageTest(TestCase):
cov.erase()
for exc in excludes or []:
cov.exclude(exc)
+ for par in partials or []:
+ cov.exclude(par, which='partial')
cov.start()
try: # pragma: recursive coverage
diff --git a/test/farm/html/gold_partial/index.html b/test/farm/html/gold_partial/index.html
new file mode 100644
index 00000000..fe945344
--- /dev/null
+++ b/test/farm/html/gold_partial/index.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
+ <title>Coverage report</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.4.3.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='jquery.hotkeys.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type='text/javascript' charset='utf-8'>
+ jQuery(document).ready(coverage.index_ready);
+ </script>
+</head>
+<body id='indexfile'>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage report:
+ <span class='pc_cov'>100%</span>
+ </h1>
+ </div>
+</div>
+
+<div id='index'>
+ <table class='index'>
+ <thead>
+
+ <tr class='tablehead' title='Click to sort'>
+ <th class='name left headerSortDown shortkey_n'>Module</th>
+ <th class='shortkey_s'>statements</th>
+ <th class='shortkey_m'>missing</th>
+ <th class='shortkey_x'>excluded</th>
+
+ <th class='shortkey_b'>branches</th>
+ <th class='shortkey_p'>partial</th>
+
+ <th class='right shortkey_c'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>8</td>
+ <td>0</td>
+ <td>0</td>
+
+ <td>6</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='partial.html'>partial</a></td>
+ <td>8</td>
+ <td>0</td>
+ <td>0</td>
+
+ <td>6</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ </tbody>
+ </table>
+</div>
+
+<div id='footer'>
+ <div class='content'>
+ <p>
+ <a class='nav' href='http://nedbatchelder.com/code/coverage/3.5a1'>coverage.py v3.5a1</a>
+ </p>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_partial/partial.html b/test/farm/html/gold_partial/partial.html
new file mode 100644
index 00000000..b9640ce4
--- /dev/null
+++ b/test/farm/html/gold_partial/partial.html
@@ -0,0 +1,121 @@
+<!doctype html PUBLIC "-//W3C//DTD html 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
+
+
+ <meta http-equiv='X-UA-Compatible' content='IE=emulateIE7' />
+ <title>Coverage for partial: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.4.3.min.js'></script>
+ <script type='text/javascript' src='jquery.hotkeys.js'></script>
+ <script type='text/javascript' src='jquery.isonscreen.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type='text/javascript' charset='utf-8'>
+ jQuery(document).ready(coverage.pyfile_ready);
+ </script>
+</head>
+<body id='pyfile'>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>partial</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <img id='keyboard_icon' src='keybd_closed.png'>
+ <h2 class='stats'>
+ 8 statements
+ <span class='run hide_run shortkey_r' onclick='coverage.toggle_lines(this, "run")'>8 run</span>
+ <span class='mis shortkey_m' onclick='coverage.toggle_lines(this, "mis")'>0 missing</span>
+ <span class='exc shortkey_x' onclick='coverage.toggle_lines(this, "exc")'>0 excluded</span>
+
+ <span class='par run hide_run shortkey_p' onclick='coverage.toggle_lines(this, "par")'>0 partial</span>
+
+ </h2>
+ </div>
+</div>
+
+<div class='help_panel'>
+ <img id='panel_icon' src='keybd_open.png'>
+<p class='legend'>Hot-keys on this page</p>
+ <div>
+<p class='keyhelp'>
+ <span class='key'>r</span>
+ <span class='key'>m</span>
+ <span class='key'>x</span>
+ <span class='key'>p</span> &nbsp; toggle line displays
+ </p>
+<p class='keyhelp'>
+ <span class='key'>j</span>
+ <span class='key'>k</span> &nbsp; next/prev highlighted chunk
+ </p>
+<p class='keyhelp'>
+ <span class='key'>0</span> &nbsp; (zero) top of page
+ </p>
+<p class='keyhelp'>
+ <span class='key'>1</span> &nbsp; (one) first highlighted chunk
+ </p>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='pln'><a href='#n1'>1</a></p>
+<p id='n2' class='pln'><a href='#n2'>2</a></p>
+<p id='n3' class='stm run hide_run'><a href='#n3'>3</a></p>
+<p id='n4' class='pln'><a href='#n4'>4</a></p>
+<p id='n5' class='stm run hide_run'><a href='#n5'>5</a></p>
+<p id='n6' class='stm run hide_run'><a href='#n6'>6</a></p>
+<p id='n7' class='pln'><a href='#n7'>7</a></p>
+<p id='n8' class='stm run hide_run'><a href='#n8'>8</a></p>
+<p id='n9' class='stm run hide_run'><a href='#n9'>9</a></p>
+<p id='n10' class='pln'><a href='#n10'>10</a></p>
+<p id='n11' class='stm run hide_run'><a href='#n11'>11</a></p>
+<p id='n12' class='stm run hide_run'><a href='#n12'>12</a></p>
+<p id='n13' class='pln'><a href='#n13'>13</a></p>
+<p id='n14' class='pln'><a href='#n14'>14</a></p>
+<p id='n15' class='pln'><a href='#n15'>15</a></p>
+<p id='n16' class='pln'><a href='#n16'>16</a></p>
+<p id='n17' class='pln'><a href='#n17'>17</a></p>
+<p id='n18' class='stm run hide_run'><a href='#n18'>18</a></p>
+<p id='n19' class='pln'><a href='#n19'>19</a></p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='pln'><span class='com'># partial branches</span><span class='strut'>&nbsp;</span></p>
+<p id='t2' class='pln'><span class='strut'>&nbsp;</span></p>
+<p id='t3' class='stm run hide_run'><span class='nam'>a</span> <span class='op'>=</span> <span class='num'>3</span><span class='strut'>&nbsp;</span></p>
+<p id='t4' class='pln'><span class='strut'>&nbsp;</span></p>
+<p id='t5' class='stm run hide_run'><span class='key'>while</span> <span class='nam'>True</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
+<p id='t6' class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>break</span><span class='strut'>&nbsp;</span></p>
+<p id='t7' class='pln'><span class='strut'>&nbsp;</span></p>
+<p id='t8' class='stm run hide_run'><span class='key'>while</span> <span class='num'>1</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
+<p id='t9' class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>break</span><span class='strut'>&nbsp;</span></p>
+<p id='t10' class='pln'><span class='strut'>&nbsp;</span></p>
+<p id='t11' class='stm run hide_run'><span class='key'>while</span> <span class='nam'>a</span><span class='op'>:</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># pragma: no branch</span><span class='strut'>&nbsp;</span></p>
+<p id='t12' class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>break</span><span class='strut'>&nbsp;</span></p>
+<p id='t13' class='pln'><span class='strut'>&nbsp;</span></p>
+<p id='t14' class='pln'><span class='key'>if</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
+<p id='t15' class='pln'>&nbsp; &nbsp; <span class='nam'>never_happen</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
+<p id='t16' class='pln'><span class='strut'>&nbsp;</span></p>
+<p id='t17' class='pln'><span class='key'>if</span> <span class='num'>1</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
+<p id='t18' class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>13</span><span class='strut'>&nbsp;</span></p>
+<p id='t19' class='pln'><span class='strut'>&nbsp;</span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+<div id='footer'>
+ <div class='content'>
+ <p>
+ <a class='nav' href='index.html'>&#xab; index</a> &nbsp; &nbsp; <a class='nav' href='http://nedbatchelder.com/code/coverage/3.5a1'>coverage.py v3.5a1</a>
+ </p>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/run_partial.py b/test/farm/html/run_partial.py
new file mode 100644
index 00000000..3fb621a1
--- /dev/null
+++ b/test/farm/html/run_partial.py
@@ -0,0 +1,27 @@
+def html_it():
+ """Run coverage and make an HTML report for partial."""
+ import coverage
+ cov = coverage.coverage(branch=True)
+ cov.start()
+ import partial
+ cov.stop()
+ cov.html_report(partial, directory="../html_partial")
+
+runfunc(html_it, rundir="src")
+
+# HTML files will change often. Check that the sizes are reasonable,
+# and check that certain key strings are in the output.
+compare("gold_partial", "html_partial", size_within=10, file_pattern="*.html")
+contains("html_partial/partial.html",
+ "<p id='t5' class='stm run hide_run'>",
+ "<p id='t8' class='stm run hide_run'>",
+ "<p id='t11' class='stm run hide_run'>",
+ # The "if 0" and "if 1" statements are optimized away.
+ "<p id='t14' class='pln'>",
+ )
+contains("html_partial/index.html",
+ "<a href='partial.html'>partial</a>",
+ "<span class='pc_cov'>100%</span>"
+ )
+
+clean("html_partial")
diff --git a/test/farm/html/src/partial.py b/test/farm/html/src/partial.py
new file mode 100644
index 00000000..9126844f
--- /dev/null
+++ b/test/farm/html/src/partial.py
@@ -0,0 +1,19 @@
+# partial branches
+
+a = 3
+
+while True:
+ break
+
+while 1:
+ break
+
+while a: # pragma: no branch
+ break
+
+if 0:
+ never_happen()
+
+if 1:
+ a = 13
+
diff --git a/test/test_api.py b/test/test_api.py
index 0a0aabfd..ae31404d 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -220,10 +220,43 @@ class ApiTest(CoverageTest):
self.assertEqual(cov.get_exclude_list(), ["foo"])
cov.exclude("bar")
self.assertEqual(cov.get_exclude_list(), ["foo", "bar"])
- self.assertEqual(cov.exclude_re, "(foo)|(bar)")
+ self.assertEqual(cov._exclude_regex('exclude'), "(foo)|(bar)")
cov.clear_exclude()
self.assertEqual(cov.get_exclude_list(), [])
+ def test_exclude_partial_list(self):
+ cov = coverage.coverage()
+ cov.clear_exclude(which='partial')
+ self.assertEqual(cov.get_exclude_list(which='partial'), [])
+ cov.exclude("foo", which='partial')
+ self.assertEqual(cov.get_exclude_list(which='partial'), ["foo"])
+ cov.exclude("bar", which='partial')
+ self.assertEqual(cov.get_exclude_list(which='partial'), ["foo", "bar"])
+ self.assertEqual(cov._exclude_regex(which='partial'), "(foo)|(bar)")
+ cov.clear_exclude(which='partial')
+ self.assertEqual(cov.get_exclude_list(which='partial'), [])
+
+ def test_exclude_and_partial_are_separate_lists(self):
+ cov = coverage.coverage()
+ cov.clear_exclude(which='partial')
+ cov.clear_exclude(which='exclude')
+ cov.exclude("foo", which='partial')
+ self.assertEqual(cov.get_exclude_list(which='partial'), ['foo'])
+ self.assertEqual(cov.get_exclude_list(which='exclude'), [])
+ cov.exclude("bar", which='exclude')
+ self.assertEqual(cov.get_exclude_list(which='partial'), ['foo'])
+ self.assertEqual(cov.get_exclude_list(which='exclude'), ['bar'])
+ cov.exclude("p2", which='partial')
+ cov.exclude("e2", which='exclude')
+ self.assertEqual(cov.get_exclude_list(which='partial'), ['foo', 'p2'])
+ self.assertEqual(cov.get_exclude_list(which='exclude'), ['bar', 'e2'])
+ cov.clear_exclude(which='partial')
+ self.assertEqual(cov.get_exclude_list(which='partial'), [])
+ self.assertEqual(cov.get_exclude_list(which='exclude'), ['bar', 'e2'])
+ cov.clear_exclude(which='exclude')
+ self.assertEqual(cov.get_exclude_list(which='partial'), [])
+ self.assertEqual(cov.get_exclude_list(which='exclude'), [])
+
def test_datafile_default(self):
# Default data file behavior: it's .coverage
self.make_file("datatest1.py", """\
diff --git a/test/test_arcs.py b/test/test_arcs.py
index a406b3a9..0c169297 100644
--- a/test/test_arcs.py
+++ b/test/test_arcs.py
@@ -213,15 +213,14 @@ class LoopArcTest(CoverageTest):
i += 1
assert a == 4 and i == 3
""",
- arcz=".1 12 34 45 36 63 57 7.",
- #arcz_missing="27" # while loop never exits naturally.
+ arcz=".1 12 23 27 34 45 36 63 57 7.",
)
# With "while True", 2.x thinks it's computation, 3.x thinks it's
# constant.
if sys.version_info >= (3, 0):
- arcz = ".1 12 34 45 36 63 57 7."
+ arcz = ".1 12 23 27 34 45 36 63 57 7."
else:
- arcz = ".1 12 34 45 36 62 57 7."
+ arcz = ".1 12 23 27 34 45 36 62 57 7."
self.check_coverage("""\
a, i = 1, 0
while True:
@@ -232,7 +231,6 @@ class LoopArcTest(CoverageTest):
assert a == 4 and i == 3
""",
arcz=arcz,
- #arcz_missing="27" # while loop never exits naturally.
)
def test_for_if_else_for(self):
@@ -481,3 +479,33 @@ class MiscArcTest(CoverageTest):
assert d
""",
arcz=".1 19 9.")
+
+
+class ExcludeTest(CoverageTest):
+ """Tests of exclusions to indicate known partial branches."""
+
+ def test_default(self):
+ # A number of forms of pragma comment are accepted.
+ self.check_coverage("""\
+ a = 1
+ if a: #pragma: no branch
+ b = 3
+ c = 4
+ if c: # pragma NOBRANCH
+ d = 6
+ e = 7
+ """,
+ [1,2,3,4,5,6,7],
+ arcz=".1 12 23 24 34 45 56 57 67 7.", arcz_missing="")
+
+ def test_custom_pragmas(self):
+ self.check_coverage("""\
+ a = 1
+ while a: # [only some]
+ c = 3
+ break
+ assert c == 5-2
+ """,
+ [1,2,3,4,5],
+ partials=["only some"],
+ arcz=".1 12 23 34 45 25 5.", arcz_missing="")
diff --git a/test/test_coverage.py b/test/test_coverage.py
index fe81da76..7c12b3a7 100644
--- a/test/test_coverage.py
+++ b/test/test_coverage.py
@@ -1155,7 +1155,7 @@ class ExcludeTest(CoverageTest):
if 0:
a = 4 # -cc
""",
- [1,3], "", ['-cc'])
+ [1,3], "", excludes=['-cc'])
def test_two_excludes(self):
self.check_coverage("""\
@@ -1167,7 +1167,7 @@ class ExcludeTest(CoverageTest):
c = 6 # -xx
assert a == 1 and b == 2
""",
- [1,3,5,7], "5", ['-cc', '-xx'])
+ [1,3,5,7], "5", excludes=['-cc', '-xx'])
def test_excluding_if_suite(self):
self.check_coverage("""\
@@ -1179,7 +1179,7 @@ class ExcludeTest(CoverageTest):
c = 6
assert a == 1 and b == 2
""",
- [1,7], "", ['if 0:'])
+ [1,7], "", excludes=['if 0:'])
def test_excluding_if_but_not_else_suite(self):
self.check_coverage("""\
@@ -1194,7 +1194,7 @@ class ExcludeTest(CoverageTest):
b = 9
assert a == 8 and b == 9
""",
- [1,8,9,10], "", ['if 0:'])
+ [1,8,9,10], "", excludes=['if 0:'])
def test_excluding_else_suite(self):
self.check_coverage("""\
@@ -1209,7 +1209,7 @@ class ExcludeTest(CoverageTest):
b = 9
assert a == 4 and b == 5 and c == 6
""",
- [1,3,4,5,6,10], "", ['#pragma: NO COVER'])
+ [1,3,4,5,6,10], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 1; b = 2
@@ -1229,7 +1229,7 @@ class ExcludeTest(CoverageTest):
b = 9
assert a == 4 and b == 5 and c == 6
""",
- [1,3,4,5,6,17], "", ['#pragma: NO COVER'])
+ [1,3,4,5,6,17], "", excludes=['#pragma: NO COVER'])
def test_excluding_elif_suites(self):
self.check_coverage("""\
@@ -1247,7 +1247,7 @@ class ExcludeTest(CoverageTest):
b = 12
assert a == 4 and b == 5 and c == 6
""",
- [1,3,4,5,6,11,12,13], "11-12", ['#pragma: NO COVER'])
+ [1,3,4,5,6,11,12,13], "11-12", excludes=['#pragma: NO COVER'])
def test_excluding_oneline_if(self):
self.check_coverage("""\
@@ -1258,7 +1258,7 @@ class ExcludeTest(CoverageTest):
foo()
""",
- [1,2,4,6], "", ["no cover"])
+ [1,2,4,6], "", excludes=["no cover"])
def test_excluding_a_colon_not_a_suite(self):
self.check_coverage("""\
@@ -1269,7 +1269,7 @@ class ExcludeTest(CoverageTest):
foo()
""",
- [1,2,4,6], "", ["no cover"])
+ [1,2,4,6], "", excludes=["no cover"])
def test_excluding_for_suite(self):
self.check_coverage("""\
@@ -1278,7 +1278,7 @@ class ExcludeTest(CoverageTest):
a += i
assert a == 15
""",
- [1,4], "", ['#pragma: NO COVER'])
+ [1,4], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
for i in [1,
@@ -1287,7 +1287,7 @@ class ExcludeTest(CoverageTest):
a += i
assert a == 15
""",
- [1,6], "", ['#pragma: NO COVER'])
+ [1,6], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
for i in [1,2,3,4,5
@@ -1297,7 +1297,7 @@ class ExcludeTest(CoverageTest):
a = 99
assert a == 1
""",
- [1,7], "", ['#pragma: NO COVER'])
+ [1,7], "", excludes=['#pragma: NO COVER'])
def test_excluding_for_else(self):
self.check_coverage("""\
@@ -1310,7 +1310,7 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 1
""",
- [1,2,3,4,5,8], "5", ['#pragma: NO COVER'])
+ [1,2,3,4,5,8], "5", excludes=['#pragma: NO COVER'])
def test_excluding_while(self):
self.check_coverage("""\
@@ -1321,7 +1321,7 @@ class ExcludeTest(CoverageTest):
b = 99
assert a == 3 and b == 0
""",
- [1,6], "", ['#pragma: NO COVER'])
+ [1,6], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 3; b = 0
while (
@@ -1332,7 +1332,7 @@ class ExcludeTest(CoverageTest):
b = 99
assert a == 3 and b == 0
""",
- [1,8], "", ['#pragma: NO COVER'])
+ [1,8], "", excludes=['#pragma: NO COVER'])
def test_excluding_while_else(self):
self.check_coverage("""\
@@ -1345,7 +1345,7 @@ class ExcludeTest(CoverageTest):
b = 123
assert a == 3 and b == 1
""",
- [1,2,3,4,5,8], "5", ['#pragma: NO COVER'])
+ [1,2,3,4,5,8], "5", excludes=['#pragma: NO COVER'])
def test_excluding_try_except(self):
self.check_coverage("""\
@@ -1356,7 +1356,7 @@ class ExcludeTest(CoverageTest):
a = 99
assert a == 1
""",
- [1,2,3,6], "", ['#pragma: NO COVER'])
+ [1,2,3,6], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
try:
@@ -1366,7 +1366,7 @@ class ExcludeTest(CoverageTest):
a = 99
assert a == 99
""",
- [1,2,3,4,5,6,7], "", ['#pragma: NO COVER'])
+ [1,2,3,4,5,6,7], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
try:
@@ -1378,7 +1378,7 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 123
""",
- [1,2,3,4,7,8,9], "", ['#pragma: NO COVER'])
+ [1,2,3,4,7,8,9], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
try:
@@ -1389,7 +1389,7 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 123
""",
- [1,2,3,7,8], "", ['#pragma: NO COVER'])
+ [1,2,3,7,8], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
try:
@@ -1401,7 +1401,7 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 99
""",
- [1,2,3,4,5,6,9], "", ['#pragma: NO COVER'])
+ [1,2,3,4,5,6,9], "", excludes=['#pragma: NO COVER'])
def test_excluding_try_except_pass(self):
self.check_coverage("""\
@@ -1412,7 +1412,7 @@ class ExcludeTest(CoverageTest):
x = 2
assert a == 1
""",
- [1,2,3,6], "", ['#pragma: NO COVER'])
+ [1,2,3,6], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
try:
@@ -1424,7 +1424,7 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 123
""",
- [1,2,3,4,7,8,9], "", ['#pragma: NO COVER'])
+ [1,2,3,4,7,8,9], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
try:
@@ -1435,7 +1435,7 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 123
""",
- [1,2,3,7,8], "", ['#pragma: NO COVER'])
+ [1,2,3,7,8], "", excludes=['#pragma: NO COVER'])
self.check_coverage("""\
a = 0
try:
@@ -1447,7 +1447,7 @@ class ExcludeTest(CoverageTest):
x = 2
assert a == 99
""",
- [1,2,3,4,5,6,9], "", ['#pragma: NO COVER'])
+ [1,2,3,4,5,6,9], "", excludes=['#pragma: NO COVER'])
def test_excluding_if_pass(self):
# From a comment on the coverage page by Michael McNeil Forbes:
@@ -1460,7 +1460,7 @@ class ExcludeTest(CoverageTest):
f()
""",
- [1,7], "", ["no cover"])
+ [1,7], "", excludes=["no cover"])
def test_excluding_function(self):
self.check_coverage("""\
@@ -1472,7 +1472,7 @@ class ExcludeTest(CoverageTest):
x = 1
assert x == 1
""",
- [6,7], "", ['#pragma: NO COVER'])
+ [6,7], "", excludes=['#pragma: NO COVER'])
def test_excluding_method(self):
self.check_coverage("""\
@@ -1486,7 +1486,7 @@ class ExcludeTest(CoverageTest):
x = Fooey()
assert x.a == 1
""",
- [1,2,3,8,9], "", ['#pragma: NO COVER'])
+ [1,2,3,8,9], "", excludes=['#pragma: NO COVER'])
def test_excluding_class(self):
self.check_coverage("""\
@@ -1500,7 +1500,7 @@ class ExcludeTest(CoverageTest):
x = 1
assert x == 1
""",
- [8,9], "", ['#pragma: NO COVER'])
+ [8,9], "", excludes=['#pragma: NO COVER'])
if sys.version_info >= (2, 4):