diff options
Diffstat (limited to 'test')
67 files changed, 2595 insertions, 659 deletions
diff --git a/test/backtest.py b/test/backtest.py index 58b1647..05a1e14 100644 --- a/test/backtest.py +++ b/test/backtest.py @@ -4,39 +4,33 @@ # (Redefining built-in blah) # The whole point of this file is to redefine built-ins, so shut up about it. -import os, sys +import os # Py2k and 3k don't agree on how to run commands in a subprocess. try: import subprocess except ImportError: - def run_command(cmd): + def run_command(cmd, status=0): """Run a command in a subprocess. - Returns the exit code and the combined stdout and stderr. + Returns the exit status code and the combined stdout and stderr. """ _, stdouterr = os.popen4(cmd) - return 0, stdouterr.read() + return status, stdouterr.read() else: - def run_command(cmd): + def run_command(cmd, status=0): """Run a command in a subprocess. - Returns the exit code and the combined stdout and stderr. + Returns the exit status code and the combined stdout and stderr. """ - if sys.hexversion > 0x03000000 and cmd.startswith("coverage "): - # We don't have a coverage command on 3.x, so fix it up to call the - # script. Eventually we won't need this. - script_path = os.path.join(sys.prefix, "Scripts", cmd) - cmd = "python " + script_path - proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) - retcode = proc.wait() + status = proc.wait() # Get the output, and canonicalize it to strings with newlines. output = proc.stdout.read() @@ -44,7 +38,7 @@ else: output = output.decode('utf-8') output = output.replace('\r', '') - return retcode, output + return status, output # No more execfile in Py3k try: diff --git a/test/backunittest.py b/test/backunittest.py index 28978c7..3e521e5 100644 --- a/test/backunittest.py +++ b/test/backunittest.py @@ -17,11 +17,17 @@ class TestCase(unittest.TestCase): the builtin `unittest` doesn't have them. """ + if _need('assertTrue'): + def assertTrue(self, exp, msg=None): + """Assert that `exp` is true.""" + if not exp: + self.fail(msg) + if _need('assertFalse'): - def assertFalse(self, exp): + def assertFalse(self, exp, msg=None): """Assert that `exp` is false.""" if exp: - self.fail() + self.fail(msg) if _need('assertRaisesRegexp'): def assertRaisesRegexp(self, excClass, regexp, callobj, *args, **kw): @@ -36,7 +42,7 @@ class TestCase(unittest.TestCase): if re.search(regexp, excMsg): # Message provided, and we got the right one: it passes. return - else: #pragma: no cover + else: # Message provided, and it didn't match: fail! raise self.failureException( "Right exception, wrong message: " @@ -44,7 +50,7 @@ class TestCase(unittest.TestCase): ) # No need to catch other exceptions: They'll fail the test all by # themselves! - else: #pragma: no cover + else: if hasattr(excClass, '__name__'): excName = excClass.__name__ else: @@ -74,10 +80,10 @@ class TestCase(unittest.TestCase): """ # Adapted from Py3.1 unittest. - self.assert_(isinstance(first, str), ( - 'First argument is not a string')) - self.assert_(isinstance(second, str), ( - 'Second argument is not a string')) + self.assertTrue(isinstance(first, str), + 'First argument is not a string') + self.assertTrue(isinstance(second, str), + 'Second argument is not a string') if first != second: msg = ''.join(difflib.ndiff(first.splitlines(True), diff --git a/test/coverage_coverage.py b/test/coverage_coverage.py index b7f903b..1e1cba0 100644 --- a/test/coverage_coverage.py +++ b/test/coverage_coverage.py @@ -1,4 +1,16 @@ -"""Coverage-test Coverage.py itself.""" +"""Coverage-test Coverage.py itself. + +Run as: + + $ python test/coverage_coverage.py run [NOSE_ARGS] + +to run and collect coverage, then: + + $ python test/coverage_coverage.py report + +to put the HTML report into the htmlcov directory. + +""" import os, shutil, sys import nose @@ -11,9 +23,9 @@ def run_tests_with_coverage(): tracer = os.environ.get('COVERAGE_TEST_TRACER', 'c') version = "%s%s" % sys.version_info[:2] - suffix = ".%s_%s" % (version, tracer) + suffix = "%s_%s" % (version, tracer) - cov = coverage.coverage(branch=True, data_suffix=suffix) + cov = coverage.coverage(config_file="covcov.ini", data_suffix=suffix) # Cheap trick: the coverage code itself is excluded from measurement, but # if we clobber the cover_prefix in the coverage object, we can defeat the # self-detection. @@ -51,18 +63,10 @@ def report_on_combined_files(): print(":: Writing HTML report to %s/index.html" % HTML_DIR) import coverage - cov = coverage.coverage() + cov = coverage.coverage(config_file="covcov.ini") cov.combine() cov.save() - cov.clear_exclude() - cov.exclude("#pragma: no cover") - cov.exclude("def __repr__") - cov.exclude("if __name__ == .__main__.:") - cov.exclude("raise AssertionError") - - cov.html_report( - directory=HTML_DIR, ignore_errors=True, omit_prefixes=["mock"] - ) + cov.html_report(directory=HTML_DIR) try: diff --git a/test/coveragetest.py b/test/coveragetest.py index 4471392..c82891e 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -38,8 +38,6 @@ class CoverageTest(TestCase): self.old_dir = os.getcwd() os.chdir(self.temp_dir) - # Preserve changes to PYTHONPATH. - self.old_pypath = os.environ.get('PYTHONPATH', '') # Modules should be importable from this temp directory. self.old_syspath = sys.path[:] @@ -48,28 +46,70 @@ class CoverageTest(TestCase): # Keep a counter to make every call to check_coverage unique. self.n = 0 - # Use a Tee to capture stdout. + # Record environment variables that we changed with set_environ. + self.environ_undos = {} + + # Capture stdout and stderr so we can examine them in tests. + # nose keeps stdout from littering the screen, so we can safely Tee it, + # but it doesn't capture stderr, so we don't want to Tee stderr to the + # real stderr, since it will interfere with our nice field of dots. self.old_stdout = sys.stdout self.captured_stdout = StringIO() sys.stdout = Tee(sys.stdout, self.captured_stdout) + self.old_stderr = sys.stderr + self.captured_stderr = StringIO() + sys.stderr = self.captured_stderr def tearDown(self): if self.run_in_temp_dir: - # Restore the original sys.path and PYTHONPATH + # Restore the original sys.path. sys.path = self.old_syspath - os.environ['PYTHONPATH'] = self.old_pypath # Get rid of the temporary directory. os.chdir(self.old_dir) shutil.rmtree(self.temp_root) - # Restore stdout. + # Restore the environment. + self.undo_environ() + + # Restore stdout and stderr sys.stdout = self.old_stdout + sys.stderr = self.old_stderr + + def set_environ(self, name, value): + """Set an environment variable `name` to be `value`. + + The environment variable is set, and record is kept that it was set, + so that `tearDown` can restore its original value. + + """ + if name not in self.environ_undos: + self.environ_undos[name] = os.environ.get(name) + os.environ[name] = value + + def original_environ(self, name): + """The environment variable `name` from when the test started.""" + if name in self.environ_undos: + return self.environ_undos[name] + else: + return os.environ.get(name) + + def undo_environ(self): + """Undo all the changes made by `set_environ`.""" + for name, value in self.environ_undos.items(): + if value is None: + del os.environ[name] + else: + os.environ[name] = value def stdout(self): """Return the data written to stdout during the test.""" return self.captured_stdout.getvalue() + def stderr(self): + """Return the data written to stderr during the test.""" + return self.captured_stderr.getvalue() + def make_file(self, filename, text): """Create a temp file. @@ -133,14 +173,22 @@ class CoverageTest(TestCase): arcs.append((self._arcz_map[a], self._arcz_map[b])) return sorted(arcs) + def assertEqualArcs(self, a1, a2): + """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" + self.assertMultiLineEqual(s1, s2) + def check_coverage(self, text, lines=None, missing="", excludes=None, report="", arcz=None, arcz_missing="", arcz_unpredicted=""): """Check the coverage measurement of `text`. The source `text` is run and measured. `lines` are the line numbers - that are executable, `missing` are the lines not executed, `excludes` - are regexes to match against for excluding lines, and `report` is - the text of the measurement report. + that are executable, or a list of possible line numbers, any of which + could match. `missing` are the lines not executed, `excludes` are + regexes to match against for excluding lines, and `report` is the text + of the measurement report. For arc measurement, `arcz` is a string that can be decoded into arcs in the code (see `arcz_to_arcs` for the encoding scheme), @@ -168,10 +216,10 @@ class CoverageTest(TestCase): cov.exclude(exc) cov.start() - try: + try: # pragma: recursive coverage # Import the python file, executing it. mod = self.import_module(modname) - finally: + finally: # pragma: recursive coverage # Stop Coverage. cov.stop() @@ -182,8 +230,12 @@ class CoverageTest(TestCase): analysis = cov._analyze(mod) if lines is not None: if type(lines[0]) == type(1): + # lines is just a list of numbers, it must match the statements + # found in the code. self.assertEqual(analysis.statements, lines) else: + # lines is a list of possible line number lists, one of them + # must match. for line_list in lines: if analysis.statements == line_list: break @@ -192,26 +244,27 @@ class CoverageTest(TestCase): analysis.statements ) - if missing is not None: - if type(missing) == type(""): - self.assertEqual(analysis.missing_formatted(), missing) + if type(missing) == type(""): + self.assertEqual(analysis.missing_formatted(), missing) + else: + for missing_list in missing: + if analysis.missing_formatted() == missing_list: + break else: - for missing_list in missing: - if analysis.missing == missing_list: - break - else: - self.fail("None of the missing choices matched %r" % - analysis.missing_formatted() - ) + self.fail("None of the missing choices matched %r" % + analysis.missing_formatted() + ) if arcs is not None: - self.assertEqual(analysis.arc_possibilities(), arcs) + self.assertEqualArcs(analysis.arc_possibilities(), arcs) if arcs_missing is not None: - self.assertEqual(analysis.arcs_missing(), arcs_missing) + self.assertEqualArcs(analysis.arcs_missing(), arcs_missing) if arcs_unpredicted is not None: - self.assertEqual(analysis.arcs_unpredicted(), arcs_unpredicted) + self.assertEqualArcs( + analysis.arcs_unpredicted(), arcs_unpredicted + ) if report: frep = StringIO() @@ -224,7 +277,7 @@ class CoverageTest(TestCase): fname = os.path.join(*fparts) return os.path.normcase(os.path.abspath(os.path.realpath(fname))) - def command_line(self, args, ret=OK): + def command_line(self, args, ret=OK, _covpkg=None): """Run `args` through the command line. Use this when you want to run the full coverage machinery, but in the @@ -236,11 +289,12 @@ class CoverageTest(TestCase): Returns None. """ - ret_actual = coverage.CoverageScript().command_line(shlex.split(args)) + script = coverage.CoverageScript(_covpkg=_covpkg) + ret_actual = script.command_line(shlex.split(args)) self.assertEqual(ret_actual, ret) def run_command(self, cmd): - """ Run the command-line `cmd` in a subprocess, and print its output. + """Run the command-line `cmd` in a subprocess, and print its output. Use this when you need to test the process behavior of coverage. @@ -249,17 +303,35 @@ class CoverageTest(TestCase): Returns the process' stdout text. """ + _, output = self.run_command_status(cmd) + return output + + def run_command_status(self, cmd, status=0): + """Run the command-line `cmd` in a subprocess, and print its output. + + Use this when you need to test the process behavior of coverage. + + Compare with `command_line`. + + Returns a pair: the process' exit status and stdout text. + + The `status` argument is returned as the status on older Pythons where + we can't get the actual exit status of the process. + + """ # Add our test modules directory to PYTHONPATH. I'm sure there's too # much path munging here, but... here = os.path.dirname(self.nice_file(coverage.__file__, "..")) testmods = self.nice_file(here, 'test/modules') zipfile = self.nice_file(here, 'test/zipmods.zip') - pypath = self.old_pypath + pypath = self.original_environ('PYTHONPATH') if pypath: pypath += os.pathsep + else: + pypath = "" pypath += testmods + os.pathsep + zipfile - os.environ['PYTHONPATH'] = pypath + self.set_environ('PYTHONPATH', pypath) - _, output = run_command(cmd) + status, output = run_command(cmd, status=status) print(output) - return output + return status, output diff --git a/test/farm/annotate/run_multi.py b/test/farm/annotate/run_multi.py index 872f097..4e8252e 100644 --- a/test/farm/annotate/run_multi.py +++ b/test/farm/annotate/run_multi.py @@ -1,7 +1,7 @@ copy("src", "out_multi") run(""" coverage -e -x multi.py - coverage -a + coverage -a """, rundir="out_multi") compare("out_multi", "gold_multi", "*,cover") clean("out_multi") diff --git a/test/farm/html/gold_a/a.html b/test/farm/html/gold_a/a.html index ed734e3..8bd4937 100644 --- a/test/farm/html/gold_a/a.html +++ b/test/farm/html/gold_a/a.html @@ -1,26 +1,14 @@ <!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 for a</title>
-<link rel='stylesheet' href='style.css' type='text/css'>
-<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
-<script type='text/javascript'>
-function toggle_lines(btn, cls) {
- var btn = $(btn);
- var hide = "hide_"+cls;
- if (btn.hasClass(hide)) {
- $("#source ."+cls).removeClass(hide);
- btn.removeClass(hide);
- }
- else {
- $("#source ."+cls).addClass(hide);
- btn.addClass(hide);
- }
-}
-</script>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
+ <title>Coverage for a: 67%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
</head>
<body>
+
<div id='header'>
<div class='content'>
<h1>Coverage for <b>a</b> :
@@ -37,30 +25,30 @@ function toggle_lines(btn, cls) { </div>
<div id='source'>
-<table cellspacing='0' cellpadding='0'>
-<tr>
-<td class='linenos' valign='top'>
-<p class='pln'>1</p>
-<p class='pln'>2</p>
-<p class='stm run hide_run'>3</p>
-<p class='pln'>4</p>
-<p class='stm run hide_run'>5</p>
-<p class='pln'>6</p>
-<p class='stm mis'>7</p>
-
-</td>
-<td class='text' valign='top'>
-<p class='pln'><span class='com'># A test file for HTML reporting by coverage.</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='key'>if</span> <span class='num'>1</span> <span class='op'><</span> <span class='num'>2</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='pln'> <span class='com'># Needed a < to look at HTML entities.</span><span class='strut'> </span></p>
-<p class='stm run hide_run'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>3</span><span class='strut'> </span></p>
-<p class='pln'><span class='key'>else</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm mis'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>4</span><span class='strut'> </span></p>
-
-</td>
-</tr>
-</table>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='pln'>1</p>
+<p id='n2' class='pln'>2</p>
+<p id='n3' class='stm run hide_run'>3</p>
+<p id='n4' class='pln'>4</p>
+<p id='n5' class='stm run hide_run'>5</p>
+<p id='n6' class='pln'>6</p>
+<p id='n7' class='stm mis'>7</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='pln'><span class='com'># A test file for HTML reporting by coverage.</span><span class='strut'> </span></p>
+<p id='t2' class='pln'><span class='strut'> </span></p>
+<p id='t3' class='stm run hide_run'><span class='key'>if</span> <span class='num'>1</span> <span class='op'><</span> <span class='num'>2</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t4' class='pln'> <span class='com'># Needed a < to look at HTML entities.</span><span class='strut'> </span></p>
+<p id='t5' class='stm run hide_run'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>3</span><span class='strut'> </span></p>
+<p id='t6' class='pln'><span class='key'>else</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t7' class='stm mis'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>4</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
</div>
</body>
diff --git a/test/farm/html/gold_a/index.html b/test/farm/html/gold_a/index.html index cb91f5c..2db6f3d 100644 --- a/test/farm/html/gold_a/index.html +++ b/test/farm/html/gold_a/index.html @@ -1,71 +1,72 @@ <!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.3.2.min.js'></script>
- <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
- <script type='text/javascript' src='coverage_html.js'></script>
- <script type="text/javascript" charset="utf-8">
- jQuery(document).ready(index_page_ready);
- </script>
- </head>
- <body>
+<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.3.2.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type="text/javascript" charset="utf-8">
+ jQuery(document).ready(index_page_ready);
+ </script>
+</head>
+<body>
- <div id='header'>
- <div class='content'>
- <h1>Coverage report:
- <span class='pc_cov'>100%</span>
- </h1>
- </div>
- </div>
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage report:
+ <span class='pc_cov'>67%</span>
+ </h1>
+ </div>
+</div>
- <div id='index'>
- <table class='index'>
- <thead>
-
- <tr class='tablehead' title='Click to sort'>
- <th class='name left headerSortDown'>Module</th>
- <th>statements</th>
- <th>run</th>
- <th>excluded</th>
-
- <th class='right'>coverage</th>
- </tr>
- </thead>
+<div id='index'>
+ <table class='index'>
+ <thead>
+
+ <tr class='tablehead' title='Click to sort'>
+ <th class='name left headerSortDown'>Module</th>
+ <th>statements</th>
+ <th>run</th>
+ <th>excluded</th>
- <tfoot>
- <tr class='total'>
- <td class='name left'>Total</td>
- <td>6</td>
- <td>6</td>
- <td>0</td>
-
- <td class='right'>100%</td>
- </tr>
- </tfoot>
- <tbody>
-
- <tr class='file'>
- <td class='name left'><a href='tabbed.html'>tabbed</a></td>
- <td>6</td>
- <td>6</td>
- <td>0</td>
-
- <td class='right'>100%</td>
- </tr>
-
- </tbody>
- </table>
- </div>
+ <th class='right'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>3</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>67%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='a.html'>a</a></td>
+ <td>3</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>67%</td>
+ </tr>
+
+ </tbody>
+ </table>
+</div>
+
+<div id='footer'>
+ <div class='content'>
+ <p>
+ <a class='nav' href='http://nedbatchelder.com/code/coverage'>coverage.py v3.3a1</a>
+ </p>
+ </div>
+</div>
- <div id='footer'>
- <div class='content'>
- <p>
- <a class='nav' href='http://nedbatchelder.com/code/coverage'>coverage.py v3.2b4</a>
- </p>
- </div>
- </div>
- </body>
+</body>
</html>
diff --git a/test/farm/html/gold_b_branch/b.html b/test/farm/html/gold_b_branch/b.html index fed2483..acb49f7 100644 --- a/test/farm/html/gold_b_branch/b.html +++ b/test/farm/html/gold_b_branch/b.html @@ -1,26 +1,14 @@ <!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 for b</title>
-<link rel='stylesheet' href='style.css' type='text/css'>
-<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
-<script type='text/javascript'>
-function toggle_lines(btn, cls) {
- var btn = $(btn);
- var hide = "hide_"+cls;
- if (btn.hasClass(hide)) {
- $("#source ."+cls).removeClass(hide);
- btn.removeClass(hide);
- }
- else {
- $("#source ."+cls).addClass(hide);
- btn.addClass(hide);
- }
-}
-</script>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
+ <title>Coverage for b: 76%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
</head>
<body>
+
<div id='header'>
<div class='content'>
<h1>Coverage for <b>b</b> :
@@ -39,72 +27,72 @@ function toggle_lines(btn, cls) { </div>
<div id='source'>
-<table cellspacing='0' cellpadding='0'>
-<tr>
-<td class='linenos' valign='top'>
-<p class='pln'>1</p>
-<p class='pln'>2</p>
-<p class='stm run hide_run'>3</p>
-<p class='pln'>4</p>
-<p class='stm par run hide_run'>5</p>
-<p class='stm run hide_run'>6</p>
-<p class='pln'>7</p>
-<p class='stm mis'>8</p>
-<p class='pln'>9</p>
-<p class='stm run hide_run'>10</p>
-<p class='pln'>11</p>
-<p class='stm run hide_run'>12</p>
-<p class='pln'>13</p>
-<p class='stm par run hide_run'>14</p>
-<p class='stm run hide_run'>15</p>
-<p class='pln'>16</p>
-<p class='stm run hide_run'>17</p>
-<p class='pln'>18</p>
-<p class='stm run hide_run'>19</p>
-<p class='pln'>20</p>
-<p class='stm par run hide_run'>21</p>
-<p class='stm run hide_run'>22</p>
-<p class='stm run hide_run'>23</p>
-<p class='pln'>24</p>
-<p class='stm mis'>25</p>
-<p class='stm run hide_run'>26</p>
-<p class='pln'>27</p>
-<p class='stm run hide_run'>28</p>
-
-</td>
-<td class='text' valign='top'>
-<p class='pln'><span class='com'># A test file for HTML reporting by coverage.</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>one</span><span class='op'>(</span><span class='nam'>x</span><span class='op'>)</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='pln'> <span class='com'># This will be a branch that misses the else.</span><span class='strut'> </span></p>
-<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>8</span> <span class='key'>if</span> <span class='nam'>x</span> <span class='op'><</span> <span class='num'>2</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm run hide_run'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>3</span><span class='strut'> </span></p>
-<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm mis'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>4</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='nam'>one</span><span class='op'>(</span><span class='num'>1</span><span class='op'>)</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>two</span><span class='op'>(</span><span class='nam'>x</span><span class='op'>)</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='pln'> <span class='com'># A missed else that branches to "exit"</span><span class='strut'> </span></p>
-<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>exit</span> <span class='key'>if</span> <span class='nam'>x</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm run hide_run'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>5</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='nam'>two</span><span class='op'>(</span><span class='num'>1</span><span class='op'>)</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>three_way</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='pln'> <span class='com'># for-else can be a three-way branch.</span><span class='strut'> </span></p>
-<p class='stm par run hide_run'><span class='annotate' title='no jumps to these line numbers'>25 26</span> <span class='key'>for</span> <span class='nam'>i</span> <span class='key'>in</span> <span class='nam'>range</span><span class='op'>(</span><span class='num'>10</span><span class='op'>)</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm run hide_run'> <span class='key'>if</span> <span class='nam'>i</span> <span class='op'>==</span> <span class='num'>3</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm run hide_run'> <span class='key'>break</span><span class='strut'> </span></p>
-<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm mis'> <span class='key'>return</span> <span class='num'>23</span><span class='strut'> </span></p>
-<p class='stm run hide_run'> <span class='key'>return</span> <span class='num'>17</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='nam'>three_way</span><span class='op'>(</span><span class='op'>)</span><span class='strut'> </span></p>
-
-</td>
-</tr>
-</table>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='pln'>1</p>
+<p id='n2' class='pln'>2</p>
+<p id='n3' class='stm run hide_run'>3</p>
+<p id='n4' class='pln'>4</p>
+<p id='n5' class='stm par run hide_run'>5</p>
+<p id='n6' class='stm run hide_run'>6</p>
+<p id='n7' class='pln'>7</p>
+<p id='n8' class='stm mis'>8</p>
+<p id='n9' class='pln'>9</p>
+<p id='n10' class='stm run hide_run'>10</p>
+<p id='n11' class='pln'>11</p>
+<p id='n12' class='stm run hide_run'>12</p>
+<p id='n13' class='pln'>13</p>
+<p id='n14' class='stm par run hide_run'>14</p>
+<p id='n15' class='stm run hide_run'>15</p>
+<p id='n16' class='pln'>16</p>
+<p id='n17' class='stm run hide_run'>17</p>
+<p id='n18' class='pln'>18</p>
+<p id='n19' class='stm run hide_run'>19</p>
+<p id='n20' class='pln'>20</p>
+<p id='n21' class='stm par run hide_run'>21</p>
+<p id='n22' class='stm run hide_run'>22</p>
+<p id='n23' class='stm run hide_run'>23</p>
+<p id='n24' class='pln'>24</p>
+<p id='n25' class='stm mis'>25</p>
+<p id='n26' class='stm run hide_run'>26</p>
+<p id='n27' class='pln'>27</p>
+<p id='n28' class='stm run hide_run'>28</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='pln'><span class='com'># A test file for HTML reporting by coverage.</span><span class='strut'> </span></p>
+<p id='t2' class='pln'><span class='strut'> </span></p>
+<p id='t3' class='stm run hide_run'><span class='key'>def</span> <span class='nam'>one</span><span class='op'>(</span><span class='nam'>x</span><span class='op'>)</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t4' class='pln'> <span class='com'># This will be a branch that misses the else.</span><span class='strut'> </span></p>
+<p id='t5' class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>8</span> <span class='key'>if</span> <span class='nam'>x</span> <span class='op'><</span> <span class='num'>2</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t6' class='stm run hide_run'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>3</span><span class='strut'> </span></p>
+<p id='t7' class='pln'> <span class='key'>else</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t8' class='stm mis'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>4</span><span class='strut'> </span></p>
+<p id='t9' class='pln'><span class='strut'> </span></p>
+<p id='t10' class='stm run hide_run'><span class='nam'>one</span><span class='op'>(</span><span class='num'>1</span><span class='op'>)</span><span class='strut'> </span></p>
+<p id='t11' class='pln'><span class='strut'> </span></p>
+<p id='t12' class='stm run hide_run'><span class='key'>def</span> <span class='nam'>two</span><span class='op'>(</span><span class='nam'>x</span><span class='op'>)</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t13' class='pln'> <span class='com'># A missed else that branches to "exit"</span><span class='strut'> </span></p>
+<p id='t14' class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>exit</span> <span class='key'>if</span> <span class='nam'>x</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t15' class='stm run hide_run'> <span class='nam'>a</span> <span class='op'>=</span> <span class='num'>5</span><span class='strut'> </span></p>
+<p id='t16' class='pln'><span class='strut'> </span></p>
+<p id='t17' class='stm run hide_run'><span class='nam'>two</span><span class='op'>(</span><span class='num'>1</span><span class='op'>)</span><span class='strut'> </span></p>
+<p id='t18' class='pln'><span class='strut'> </span></p>
+<p id='t19' class='stm run hide_run'><span class='key'>def</span> <span class='nam'>three_way</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t20' class='pln'> <span class='com'># for-else can be a three-way branch.</span><span class='strut'> </span></p>
+<p id='t21' class='stm par run hide_run'><span class='annotate' title='no jumps to these line numbers'>25 26</span> <span class='key'>for</span> <span class='nam'>i</span> <span class='key'>in</span> <span class='nam'>range</span><span class='op'>(</span><span class='num'>10</span><span class='op'>)</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t22' class='stm run hide_run'> <span class='key'>if</span> <span class='nam'>i</span> <span class='op'>==</span> <span class='num'>3</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t23' class='stm run hide_run'> <span class='key'>break</span><span class='strut'> </span></p>
+<p id='t24' class='pln'> <span class='key'>else</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t25' class='stm mis'> <span class='key'>return</span> <span class='num'>23</span><span class='strut'> </span></p>
+<p id='t26' class='stm run hide_run'> <span class='key'>return</span> <span class='num'>17</span><span class='strut'> </span></p>
+<p id='t27' class='pln'><span class='strut'> </span></p>
+<p id='t28' class='stm run hide_run'><span class='nam'>three_way</span><span class='op'>(</span><span class='op'>)</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
</div>
</body>
diff --git a/test/farm/html/gold_b_branch/index.html b/test/farm/html/gold_b_branch/index.html index 0100602..84648cd 100644 --- a/test/farm/html/gold_b_branch/index.html +++ b/test/farm/html/gold_b_branch/index.html @@ -1,80 +1,81 @@ <!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.3.2.min.js'></script>
- <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
- <script type='text/javascript' src='coverage_html.js'></script>
- <script type="text/javascript" charset="utf-8">
- jQuery(document).ready(index_page_ready);
- </script>
- </head>
- <body>
+<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.3.2.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type="text/javascript" charset="utf-8">
+ jQuery(document).ready(index_page_ready);
+ </script>
+</head>
+<body>
- <div id='header'>
- <div class='content'>
- <h1>Coverage report:
- <span class='pc_cov'>77%</span>
- </h1>
- </div>
- </div>
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage report:
+ <span class='pc_cov'>76%</span>
+ </h1>
+ </div>
+</div>
- <div id='index'>
- <table class='index'>
- <thead>
-
- <tr class='tablehead' title='Click to sort'>
- <th class='name left headerSortDown'>Module</th>
- <th>statements</th>
- <th>run</th>
- <th>excluded</th>
-
- <th>branches</th>
- <th>br exec</th>
-
- <th class='right'>coverage</th>
- </tr>
- </thead>
+<div id='index'>
+ <table class='index'>
+ <thead>
+
+ <tr class='tablehead' title='Click to sort'>
+ <th class='name left headerSortDown'>Module</th>
+ <th>statements</th>
+ <th>run</th>
+ <th>excluded</th>
- <tfoot>
- <tr class='total'>
- <td class='name left'>Total</td>
- <td>9</td>
- <td>8</td>
- <td>0</td>
-
- <td>4</td>
- <td>2</td>
-
- <td class='right'>77%</td>
- </tr>
- </tfoot>
- <tbody>
-
- <tr class='file'>
- <td class='name left'><a href='b.html'>b</a></td>
- <td>9</td>
- <td>8</td>
- <td>0</td>
-
- <td>4</td>
- <td>2</td>
-
- <td class='right'>77%</td>
- </tr>
-
- </tbody>
- </table>
- </div>
+ <th>branches</th>
+ <th>br exec</th>
+
+ <th class='right'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>16</td>
+ <td>14</td>
+ <td>0</td>
+
+ <td>9</td>
+ <td>5</td>
+
+ <td class='right'>76%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='b.html'>b</a></td>
+ <td>16</td>
+ <td>14</td>
+ <td>0</td>
+
+ <td>9</td>
+ <td>5</td>
+
+ <td class='right'>76%</td>
+ </tr>
+
+ </tbody>
+ </table>
+</div>
+
+<div id='footer'>
+ <div class='content'>
+ <p>
+ <a class='nav' href='http://nedbatchelder.com/code/coverage'>coverage.py v3.3a1</a>
+ </p>
+ </div>
+</div>
- <div id='footer'>
- <div class='content'>
- <p>
- <a class='nav' href='http://nedbatchelder.com/code/coverage'>coverage.py v3.2b4</a>
- </p>
- </div>
- </div>
- </body>
+</body>
</html>
diff --git a/test/farm/html/gold_omit_1/index.html b/test/farm/html/gold_omit_1/index.html new file mode 100644 index 0000000..6a4086b --- /dev/null +++ b/test/farm/html/gold_omit_1/index.html @@ -0,0 +1,99 @@ +<!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.3.2.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type='text/javascript' charset='utf-8'>
+ jQuery(document).ready(index_page_ready);
+ </script>
+</head>
+<body>
+
+<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'>Module</th>
+ <th>statements</th>
+ <th>run</th>
+ <th>excluded</th>
+
+ <th class='right'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>14</td>
+ <td>14</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='m1.html'>m1</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='m2.html'>m2</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='m3.html'>m3</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='main.html'>main</a></td>
+ <td>8</td>
+ <td>8</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'>coverage.py v3.3a1</a>
+ </p>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_1/m1.html b/test/farm/html/gold_omit_1/m1.html new file mode 100644 index 0000000..ba3a527 --- /dev/null +++ b/test/farm/html/gold_omit_1/m1.html @@ -0,0 +1,45 @@ +<!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 for m1: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m1</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m1a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m1b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_1/m2.html b/test/farm/html/gold_omit_1/m2.html new file mode 100644 index 0000000..bd9e4c4 --- /dev/null +++ b/test/farm/html/gold_omit_1/m2.html @@ -0,0 +1,45 @@ +<!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 for m2: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m2</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m2a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m2b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_1/m3.html b/test/farm/html/gold_omit_1/m3.html new file mode 100644 index 0000000..cdd6760 --- /dev/null +++ b/test/farm/html/gold_omit_1/m3.html @@ -0,0 +1,45 @@ +<!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 for m3: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m3</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m3a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m3b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_1/main.html b/test/farm/html/gold_omit_1/main.html new file mode 100644 index 0000000..4c159fd --- /dev/null +++ b/test/farm/html/gold_omit_1/main.html @@ -0,0 +1,61 @@ +<!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 for main: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>main</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 8 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>8 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+<p id='n3' class='stm run hide_run'>3</p>
+<p id='n4' class='pln'>4</p>
+<p id='n5' class='stm run hide_run'>5</p>
+<p id='n6' class='stm run hide_run'>6</p>
+<p id='n7' class='pln'>7</p>
+<p id='n8' class='stm run hide_run'>8</p>
+<p id='n9' class='stm run hide_run'>9</p>
+<p id='n10' class='stm run hide_run'>10</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m2</span><span class='strut'> </span></p>
+<p id='t3' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m3</span><span class='strut'> </span></p>
+<p id='t4' class='pln'><span class='strut'> </span></p>
+<p id='t5' class='stm run hide_run'><span class='nam'>a</span> <span class='op'>=</span> <span class='num'>5</span><span class='strut'> </span></p>
+<p id='t6' class='stm run hide_run'><span class='nam'>b</span> <span class='op'>=</span> <span class='num'>6</span><span class='strut'> </span></p>
+<p id='t7' class='pln'><span class='strut'> </span></p>
+<p id='t8' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m1</span><span class='op'>.</span><span class='nam'>m1a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t9' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m2</span><span class='op'>.</span><span class='nam'>m2a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t10' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m3</span><span class='op'>.</span><span class='nam'>m3a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_2/index.html b/test/farm/html/gold_omit_2/index.html new file mode 100644 index 0000000..c47c368 --- /dev/null +++ b/test/farm/html/gold_omit_2/index.html @@ -0,0 +1,90 @@ +<!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.3.2.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type='text/javascript' charset='utf-8'>
+ jQuery(document).ready(index_page_ready);
+ </script>
+</head>
+<body>
+
+<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'>Module</th>
+ <th>statements</th>
+ <th>run</th>
+ <th>excluded</th>
+
+ <th class='right'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>12</td>
+ <td>12</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='m2.html'>m2</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='m3.html'>m3</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='main.html'>main</a></td>
+ <td>8</td>
+ <td>8</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'>coverage.py v3.3a1</a>
+ </p>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_2/m2.html b/test/farm/html/gold_omit_2/m2.html new file mode 100644 index 0000000..bd9e4c4 --- /dev/null +++ b/test/farm/html/gold_omit_2/m2.html @@ -0,0 +1,45 @@ +<!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 for m2: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m2</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m2a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m2b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_2/m3.html b/test/farm/html/gold_omit_2/m3.html new file mode 100644 index 0000000..cdd6760 --- /dev/null +++ b/test/farm/html/gold_omit_2/m3.html @@ -0,0 +1,45 @@ +<!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 for m3: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m3</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m3a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m3b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_2/main.html b/test/farm/html/gold_omit_2/main.html new file mode 100644 index 0000000..4c159fd --- /dev/null +++ b/test/farm/html/gold_omit_2/main.html @@ -0,0 +1,61 @@ +<!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 for main: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>main</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 8 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>8 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+<p id='n3' class='stm run hide_run'>3</p>
+<p id='n4' class='pln'>4</p>
+<p id='n5' class='stm run hide_run'>5</p>
+<p id='n6' class='stm run hide_run'>6</p>
+<p id='n7' class='pln'>7</p>
+<p id='n8' class='stm run hide_run'>8</p>
+<p id='n9' class='stm run hide_run'>9</p>
+<p id='n10' class='stm run hide_run'>10</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m2</span><span class='strut'> </span></p>
+<p id='t3' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m3</span><span class='strut'> </span></p>
+<p id='t4' class='pln'><span class='strut'> </span></p>
+<p id='t5' class='stm run hide_run'><span class='nam'>a</span> <span class='op'>=</span> <span class='num'>5</span><span class='strut'> </span></p>
+<p id='t6' class='stm run hide_run'><span class='nam'>b</span> <span class='op'>=</span> <span class='num'>6</span><span class='strut'> </span></p>
+<p id='t7' class='pln'><span class='strut'> </span></p>
+<p id='t8' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m1</span><span class='op'>.</span><span class='nam'>m1a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t9' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m2</span><span class='op'>.</span><span class='nam'>m2a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t10' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m3</span><span class='op'>.</span><span class='nam'>m3a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_3/index.html b/test/farm/html/gold_omit_3/index.html new file mode 100644 index 0000000..c217f0d --- /dev/null +++ b/test/farm/html/gold_omit_3/index.html @@ -0,0 +1,81 @@ +<!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.3.2.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type='text/javascript' charset='utf-8'>
+ jQuery(document).ready(index_page_ready);
+ </script>
+</head>
+<body>
+
+<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'>Module</th>
+ <th>statements</th>
+ <th>run</th>
+ <th>excluded</th>
+
+ <th class='right'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>10</td>
+ <td>10</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='m3.html'>m3</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='main.html'>main</a></td>
+ <td>8</td>
+ <td>8</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'>coverage.py v3.3a1</a>
+ </p>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_3/m3.html b/test/farm/html/gold_omit_3/m3.html new file mode 100644 index 0000000..cdd6760 --- /dev/null +++ b/test/farm/html/gold_omit_3/m3.html @@ -0,0 +1,45 @@ +<!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 for m3: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m3</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m3a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m3b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_3/main.html b/test/farm/html/gold_omit_3/main.html new file mode 100644 index 0000000..4c159fd --- /dev/null +++ b/test/farm/html/gold_omit_3/main.html @@ -0,0 +1,61 @@ +<!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 for main: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>main</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 8 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>8 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+<p id='n3' class='stm run hide_run'>3</p>
+<p id='n4' class='pln'>4</p>
+<p id='n5' class='stm run hide_run'>5</p>
+<p id='n6' class='stm run hide_run'>6</p>
+<p id='n7' class='pln'>7</p>
+<p id='n8' class='stm run hide_run'>8</p>
+<p id='n9' class='stm run hide_run'>9</p>
+<p id='n10' class='stm run hide_run'>10</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m2</span><span class='strut'> </span></p>
+<p id='t3' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m3</span><span class='strut'> </span></p>
+<p id='t4' class='pln'><span class='strut'> </span></p>
+<p id='t5' class='stm run hide_run'><span class='nam'>a</span> <span class='op'>=</span> <span class='num'>5</span><span class='strut'> </span></p>
+<p id='t6' class='stm run hide_run'><span class='nam'>b</span> <span class='op'>=</span> <span class='num'>6</span><span class='strut'> </span></p>
+<p id='t7' class='pln'><span class='strut'> </span></p>
+<p id='t8' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m1</span><span class='op'>.</span><span class='nam'>m1a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t9' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m2</span><span class='op'>.</span><span class='nam'>m2a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t10' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m3</span><span class='op'>.</span><span class='nam'>m3a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_4/index.html b/test/farm/html/gold_omit_4/index.html new file mode 100644 index 0000000..321ccdc --- /dev/null +++ b/test/farm/html/gold_omit_4/index.html @@ -0,0 +1,90 @@ +<!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.3.2.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type='text/javascript' charset='utf-8'>
+ jQuery(document).ready(index_page_ready);
+ </script>
+</head>
+<body>
+
+<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'>Module</th>
+ <th>statements</th>
+ <th>run</th>
+ <th>excluded</th>
+
+ <th class='right'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>12</td>
+ <td>12</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='m1.html'>m1</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='m3.html'>m3</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='main.html'>main</a></td>
+ <td>8</td>
+ <td>8</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'>coverage.py v3.3a1</a>
+ </p>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_4/m1.html b/test/farm/html/gold_omit_4/m1.html new file mode 100644 index 0000000..ba3a527 --- /dev/null +++ b/test/farm/html/gold_omit_4/m1.html @@ -0,0 +1,45 @@ +<!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 for m1: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m1</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m1a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m1b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_4/m3.html b/test/farm/html/gold_omit_4/m3.html new file mode 100644 index 0000000..cdd6760 --- /dev/null +++ b/test/farm/html/gold_omit_4/m3.html @@ -0,0 +1,45 @@ +<!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 for m3: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m3</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m3a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m3b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_4/main.html b/test/farm/html/gold_omit_4/main.html new file mode 100644 index 0000000..4c159fd --- /dev/null +++ b/test/farm/html/gold_omit_4/main.html @@ -0,0 +1,61 @@ +<!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 for main: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>main</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 8 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>8 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+<p id='n3' class='stm run hide_run'>3</p>
+<p id='n4' class='pln'>4</p>
+<p id='n5' class='stm run hide_run'>5</p>
+<p id='n6' class='stm run hide_run'>6</p>
+<p id='n7' class='pln'>7</p>
+<p id='n8' class='stm run hide_run'>8</p>
+<p id='n9' class='stm run hide_run'>9</p>
+<p id='n10' class='stm run hide_run'>10</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m2</span><span class='strut'> </span></p>
+<p id='t3' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m3</span><span class='strut'> </span></p>
+<p id='t4' class='pln'><span class='strut'> </span></p>
+<p id='t5' class='stm run hide_run'><span class='nam'>a</span> <span class='op'>=</span> <span class='num'>5</span><span class='strut'> </span></p>
+<p id='t6' class='stm run hide_run'><span class='nam'>b</span> <span class='op'>=</span> <span class='num'>6</span><span class='strut'> </span></p>
+<p id='t7' class='pln'><span class='strut'> </span></p>
+<p id='t8' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m1</span><span class='op'>.</span><span class='nam'>m1a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t9' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m2</span><span class='op'>.</span><span class='nam'>m2a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t10' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m3</span><span class='op'>.</span><span class='nam'>m3a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_5/index.html b/test/farm/html/gold_omit_5/index.html new file mode 100644 index 0000000..79c5d07 --- /dev/null +++ b/test/farm/html/gold_omit_5/index.html @@ -0,0 +1,81 @@ +<!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.3.2.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type='text/javascript' charset='utf-8'>
+ jQuery(document).ready(index_page_ready);
+ </script>
+</head>
+<body>
+
+<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'>Module</th>
+ <th>statements</th>
+ <th>run</th>
+ <th>excluded</th>
+
+ <th class='right'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>10</td>
+ <td>10</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='m1.html'>m1</a></td>
+ <td>2</td>
+ <td>2</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='main.html'>main</a></td>
+ <td>8</td>
+ <td>8</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'>coverage.py v3.3a1</a>
+ </p>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_5/m1.html b/test/farm/html/gold_omit_5/m1.html new file mode 100644 index 0000000..ba3a527 --- /dev/null +++ b/test/farm/html/gold_omit_5/m1.html @@ -0,0 +1,45 @@ +<!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 for m1: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>m1</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 2 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='nam'>m1a</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='nam'>m1b</span> <span class='op'>=</span> <span class='num'>2</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_omit_5/main.html b/test/farm/html/gold_omit_5/main.html new file mode 100644 index 0000000..4c159fd --- /dev/null +++ b/test/farm/html/gold_omit_5/main.html @@ -0,0 +1,61 @@ +<!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 for main: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+</head>
+<body>
+
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>main</b> :
+ <span class='pc_cov'>100%</span>
+ </h1>
+ <h2 class='stats'>
+ 8 statements
+ <span class='run hide_run' onclick='toggle_lines(this, "run")'>8 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>0 missing</span>
+
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='stm run hide_run'>1</p>
+<p id='n2' class='stm run hide_run'>2</p>
+<p id='n3' class='stm run hide_run'>3</p>
+<p id='n4' class='pln'>4</p>
+<p id='n5' class='stm run hide_run'>5</p>
+<p id='n6' class='stm run hide_run'>6</p>
+<p id='n7' class='pln'>7</p>
+<p id='n8' class='stm run hide_run'>8</p>
+<p id='n9' class='stm run hide_run'>9</p>
+<p id='n10' class='stm run hide_run'>10</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m1</span><span class='strut'> </span></p>
+<p id='t2' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m2</span><span class='strut'> </span></p>
+<p id='t3' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>m3</span><span class='strut'> </span></p>
+<p id='t4' class='pln'><span class='strut'> </span></p>
+<p id='t5' class='stm run hide_run'><span class='nam'>a</span> <span class='op'>=</span> <span class='num'>5</span><span class='strut'> </span></p>
+<p id='t6' class='stm run hide_run'><span class='nam'>b</span> <span class='op'>=</span> <span class='num'>6</span><span class='strut'> </span></p>
+<p id='t7' class='pln'><span class='strut'> </span></p>
+<p id='t8' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m1</span><span class='op'>.</span><span class='nam'>m1a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t9' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m2</span><span class='op'>.</span><span class='nam'>m2a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+<p id='t10' class='stm run hide_run'><span class='key'>assert</span> <span class='nam'>m3</span><span class='op'>.</span><span class='nam'>m3a</span> <span class='op'>==</span> <span class='num'>1</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+</html>
diff --git a/test/farm/html/gold_other/blah_blah_other.html b/test/farm/html/gold_other/blah_blah_other.html index f8f6b8b..ebb2134 100644 --- a/test/farm/html/gold_other/blah_blah_other.html +++ b/test/farm/html/gold_other/blah_blah_other.html @@ -1,26 +1,14 @@ <!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 for c:\ned\coverage\trunk\test\farm\html\othersrc\other</title>
-<link rel='stylesheet' href='style.css' type='text/css'>
-<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
-<script type='text/javascript'>
-function toggle_lines(btn, cls) {
- var btn = $(btn);
- var hide = "hide_"+cls;
- if (btn.hasClass(hide)) {
- $("#source ."+cls).removeClass(hide);
- btn.removeClass(hide);
- }
- else {
- $("#source ."+cls).addClass(hide);
- btn.addClass(hide);
- }
-}
-</script>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
+ <title>Coverage for c:\ned\coverage\trunk\test\farm\html\othersrc\other: 100%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
</head>
<body>
+
<div id='header'>
<div class='content'>
<h1>Coverage for <b>c:\ned\coverage\trunk\test\farm\html\othersrc\other</b> :
@@ -37,24 +25,24 @@ function toggle_lines(btn, cls) { </div>
<div id='source'>
-<table cellspacing='0' cellpadding='0'>
-<tr>
-<td class='linenos' valign='top'>
-<p class='pln'>1</p>
-<p class='pln'>2</p>
-<p class='pln'>3</p>
-<p class='stm run hide_run'>4</p>
-
-</td>
-<td class='text' valign='top'>
-<p class='pln'><span class='com'># A file in another directory. We're checking that it ends up in the</span><span class='strut'> </span></p>
-<p class='pln'><span class='com'># HTML report.</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='key'>print</span><span class='op'>(</span><span class='str'>"This is the other src!"</span><span class='op'>)</span><span class='strut'> </span></p>
-
-</td>
-</tr>
-</table>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='pln'>1</p>
+<p id='n2' class='pln'>2</p>
+<p id='n3' class='pln'>3</p>
+<p id='n4' class='stm run hide_run'>4</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='pln'><span class='com'># A file in another directory. We're checking that it ends up in the</span><span class='strut'> </span></p>
+<p id='t2' class='pln'><span class='com'># HTML report.</span><span class='strut'> </span></p>
+<p id='t3' class='pln'><span class='strut'> </span></p>
+<p id='t4' class='stm run hide_run'><span class='key'>print</span><span class='op'>(</span><span class='str'>"This is the other src!"</span><span class='op'>)</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
</div>
</body>
diff --git a/test/farm/html/gold_other/here.html b/test/farm/html/gold_other/here.html index 961fdfa..ff7d2ad 100644 --- a/test/farm/html/gold_other/here.html +++ b/test/farm/html/gold_other/here.html @@ -1,26 +1,14 @@ <!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 for here</title>
-<link rel='stylesheet' href='style.css' type='text/css'>
-<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
-<script type='text/javascript'>
-function toggle_lines(btn, cls) {
- var btn = $(btn);
- var hide = "hide_"+cls;
- if (btn.hasClass(hide)) {
- $("#source ."+cls).removeClass(hide);
- btn.removeClass(hide);
- }
- else {
- $("#source ."+cls).addClass(hide);
- btn.addClass(hide);
- }
-}
-</script>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
+ <title>Coverage for here: 75%</title>
+ <link rel='stylesheet' href='style.css' type='text/css'>
+ <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
</head>
<body>
+
<div id='header'>
<div class='content'>
<h1>Coverage for <b>here</b> :
@@ -37,32 +25,32 @@ function toggle_lines(btn, cls) { </div>
<div id='source'>
-<table cellspacing='0' cellpadding='0'>
-<tr>
-<td class='linenos' valign='top'>
-<p class='pln'>1</p>
-<p class='pln'>2</p>
-<p class='stm run hide_run'>3</p>
-<p class='pln'>4</p>
-<p class='stm run hide_run'>5</p>
-<p class='stm run hide_run'>6</p>
-<p class='pln'>7</p>
-<p class='stm mis'>8</p>
-
-</td>
-<td class='text' valign='top'>
-<p class='pln'><span class='com'># A test file for HTML reporting by coverage.</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='key'>import</span> <span class='nam'>other</span><span class='strut'> </span></p>
-<p class='pln'><span class='strut'> </span></p>
-<p class='stm run hide_run'><span class='key'>if</span> <span class='num'>1</span> <span class='op'><</span> <span class='num'>2</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm run hide_run'> <span class='nam'>h</span> <span class='op'>=</span> <span class='num'>3</span><span class='strut'> </span></p>
-<p class='pln'><span class='key'>else</span><span class='op'>:</span><span class='strut'> </span></p>
-<p class='stm mis'> <span class='nam'>h</span> <span class='op'>=</span> <span class='num'>4</span><span class='strut'> </span></p>
-
-</td>
-</tr>
-</table>
+ <table cellspacing='0' cellpadding='0'>
+ <tr>
+ <td class='linenos' valign='top'>
+<p id='n1' class='pln'>1</p>
+<p id='n2' class='pln'>2</p>
+<p id='n3' class='stm run hide_run'>3</p>
+<p id='n4' class='pln'>4</p>
+<p id='n5' class='stm run hide_run'>5</p>
+<p id='n6' class='stm run hide_run'>6</p>
+<p id='n7' class='pln'>7</p>
+<p id='n8' class='stm mis'>8</p>
+
+ </td>
+ <td class='text' valign='top'>
+<p id='t1' class='pln'><span class='com'># A test file for HTML reporting by coverage.</span><span class='strut'> </span></p>
+<p id='t2' class='pln'><span class='strut'> </span></p>
+<p id='t3' class='stm run hide_run'><span class='key'>import</span> <span class='nam'>other</span><span class='strut'> </span></p>
+<p id='t4' class='pln'><span class='strut'> </span></p>
+<p id='t5' class='stm run hide_run'><span class='key'>if</span> <span class='num'>1</span> <span class='op'><</span> <span class='num'>2</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t6' class='stm run hide_run'> <span class='nam'>h</span> <span class='op'>=</span> <span class='num'>3</span><span class='strut'> </span></p>
+<p id='t7' class='pln'><span class='key'>else</span><span class='op'>:</span><span class='strut'> </span></p>
+<p id='t8' class='stm mis'> <span class='nam'>h</span> <span class='op'>=</span> <span class='num'>4</span><span class='strut'> </span></p>
+
+ </td>
+ </tr>
+ </table>
</div>
</body>
diff --git a/test/farm/html/gold_other/index.html b/test/farm/html/gold_other/index.html index b392c7f..e9e1fd2 100644 --- a/test/farm/html/gold_other/index.html +++ b/test/farm/html/gold_other/index.html @@ -1,80 +1,81 @@ <!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.3.2.min.js'></script>
- <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
- <script type='text/javascript' src='coverage_html.js'></script>
- <script type="text/javascript" charset="utf-8">
- jQuery(document).ready(index_page_ready);
- </script>
- </head>
- <body>
+<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.3.2.min.js'></script>
+ <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
+ <script type='text/javascript' src='coverage_html.js'></script>
+ <script type="text/javascript" charset="utf-8">
+ jQuery(document).ready(index_page_ready);
+ </script>
+</head>
+<body>
- <div id='header'>
- <div class='content'>
- <h1>Coverage report:
- <span class='pc_cov'>80%</span>
- </h1>
- </div>
- </div>
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage report:
+ <span class='pc_cov'>80%</span>
+ </h1>
+ </div>
+</div>
- <div id='index'>
- <table class='index'>
- <thead>
-
- <tr class='tablehead' title='Click to sort'>
- <th class='name left headerSortDown'>Module</th>
- <th>statements</th>
- <th>run</th>
- <th>excluded</th>
-
- <th class='right'>coverage</th>
- </tr>
- </thead>
+<div id='index'>
+ <table class='index'>
+ <thead>
+
+ <tr class='tablehead' title='Click to sort'>
+ <th class='name left headerSortDown'>Module</th>
+ <th>statements</th>
+ <th>run</th>
+ <th>excluded</th>
- <tfoot>
- <tr class='total'>
- <td class='name left'>Total</td>
- <td>5</td>
- <td>4</td>
- <td>0</td>
-
- <td class='right'>80%</td>
- </tr>
- </tfoot>
- <tbody>
-
- <tr class='file'>
- <td class='name left'><a href='_ned_coverage_trunk_test_farm_html_othersrc_other.html'>c:\ned\coverage\trunk\test\farm\html\othersrc\other</a></td>
- <td>1</td>
- <td>1</td>
- <td>0</td>
-
- <td class='right'>100%</td>
- </tr>
-
- <tr class='file'>
- <td class='name left'><a href='here.html'>here</a></td>
- <td>4</td>
- <td>3</td>
- <td>0</td>
-
- <td class='right'>75%</td>
- </tr>
-
- </tbody>
- </table>
- </div>
+ <th class='right'>coverage</th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr class='total'>
+ <td class='name left'>Total</td>
+ <td>5</td>
+ <td>4</td>
+ <td>0</td>
+
+ <td class='right'>80%</td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class='file'>
+ <td class='name left'><a href='_ned_coverage_trunk_test_farm_html_othersrc_other.html'>c:\ned\coverage\trunk\test\farm\html\othersrc\other</a></td>
+ <td>1</td>
+ <td>1</td>
+ <td>0</td>
+
+ <td class='right'>100%</td>
+ </tr>
+
+ <tr class='file'>
+ <td class='name left'><a href='here.html'>here</a></td>
+ <td>4</td>
+ <td>3</td>
+ <td>0</td>
+
+ <td class='right'>75%</td>
+ </tr>
+
+ </tbody>
+ </table>
+</div>
+
+<div id='footer'>
+ <div class='content'>
+ <p>
+ <a class='nav' href='http://nedbatchelder.com/code/coverage'>coverage.py v3.3a1</a>
+ </p>
+ </div>
+</div>
- <div id='footer'>
- <div class='content'>
- <p>
- <a class='nav' href='http://nedbatchelder.com/code/coverage'>coverage.py v3.2b4</a>
- </p>
- </div>
- </div>
- </body>
+</body>
</html>
diff --git a/test/farm/html/gold_x_xml/coverage.xml b/test/farm/html/gold_x_xml/coverage.xml index 8c009f5..37027ef 100644 --- a/test/farm/html/gold_x_xml/coverage.xml +++ b/test/farm/html/gold_x_xml/coverage.xml @@ -6,7 +6,7 @@ <packages>
<package branch-rate="0.0" complexity="0.0" line-rate="0.666666666667" name=".">
<classes>
- <class branch-rate="0.0" complexity="0.0" filename="x.py" line-rate="0.666666666667" name="x">
+ <class branch-rate="0.0" complexity="0.0" filename="a.py" line-rate="0.666666666667" name="a">
<methods/>
<lines>
<line hits="1" number="3"/>
diff --git a/test/farm/html/run_x_xml.py b/test/farm/html/run_a_xml_1.py index fe9cefa..7f4805e 100644 --- a/test/farm/html/run_x_xml.py +++ b/test/farm/html/run_a_xml_1.py @@ -1,20 +1,20 @@ def html_it(): - """Run coverage and make an XML report for x.""" + """Run coverage and make an XML report for a.""" import coverage cov = coverage.coverage() cov.start() - import x + import a cov.stop() - cov.xml_report(x, outfile="../xml/coverage.xml") + cov.xml_report(a, outfile="../xml_1/coverage.xml") import os -if not os.path.exists("xml"): - os.makedirs("xml") +if not os.path.exists("xml_1"): + os.makedirs("xml_1") runfunc(html_it, rundir="src") -compare("gold_x_xml", "xml", scrubs=[ +compare("gold_x_xml", "xml_1", scrubs=[ (r' timestamp="\d+"', ' timestamp="TIMESTAMP"'), (r' version="[-.\w]+"', ' version="VERSION"'), ]) -clean("xml") +clean("xml_1") diff --git a/test/farm/html/run_a_xml_2.py b/test/farm/html/run_a_xml_2.py new file mode 100644 index 0000000..b08d796 --- /dev/null +++ b/test/farm/html/run_a_xml_2.py @@ -0,0 +1,20 @@ +def html_it(): + """Run coverage and make an XML report for a.""" + import coverage + cov = coverage.coverage(config_file="run_a_xml_2.ini") + cov.start() + import a + cov.stop() + cov.xml_report(a) + +import os +if not os.path.exists("xml_2"): + os.makedirs("xml_2") + +runfunc(html_it, rundir="src") + +compare("gold_x_xml", "xml_2", scrubs=[ + (r' timestamp="\d+"', ' timestamp="TIMESTAMP"'), + (r' version="[-.\w]+"', ' version="VERSION"'), + ]) +clean("xml_2") diff --git a/test/farm/html/run_omit_1.py b/test/farm/html/run_omit_1.py new file mode 100644 index 0000000..a493a8a --- /dev/null +++ b/test/farm/html/run_omit_1.py @@ -0,0 +1,12 @@ +def html_it(): + """Run coverage and make an HTML report for main.""" + import coverage + cov = coverage.coverage() + cov.start() + import main + cov.stop() + cov.html_report(directory="../html_omit_1") + +runfunc(html_it, rundir="src") +compare("gold_omit_1", "html_omit_1", size_within=10, file_pattern="*.html") +clean("html_omit_1") diff --git a/test/farm/html/run_omit_2.py b/test/farm/html/run_omit_2.py new file mode 100644 index 0000000..5d7e832 --- /dev/null +++ b/test/farm/html/run_omit_2.py @@ -0,0 +1,12 @@ +def html_it(): + """Run coverage and make an HTML report for main.""" + import coverage + cov = coverage.coverage() + cov.start() + import main + cov.stop() + cov.html_report(directory="../html_omit_2", omit_prefixes=["m1"]) + +runfunc(html_it, rundir="src") +compare("gold_omit_2", "html_omit_2", size_within=10, file_pattern="*.html") +clean("html_omit_2") diff --git a/test/farm/html/run_omit_3.py b/test/farm/html/run_omit_3.py new file mode 100644 index 0000000..537ec2c --- /dev/null +++ b/test/farm/html/run_omit_3.py @@ -0,0 +1,12 @@ +def html_it(): + """Run coverage and make an HTML report for main.""" + import coverage + cov = coverage.coverage() + cov.start() + import main + cov.stop() + cov.html_report(directory="../html_omit_3", omit_prefixes=["m1", "m2"]) + +runfunc(html_it, rundir="src") +compare("gold_omit_3", "html_omit_3", size_within=10, file_pattern="*.html") +clean("html_omit_3") diff --git a/test/farm/html/run_omit_4.py b/test/farm/html/run_omit_4.py new file mode 100644 index 0000000..c62e9d5 --- /dev/null +++ b/test/farm/html/run_omit_4.py @@ -0,0 +1,12 @@ +def html_it(): + """Run coverage and make an HTML report for main.""" + import coverage + cov = coverage.coverage(config_file="omit4.ini") + cov.start() + import main + cov.stop() + cov.html_report(directory="../html_omit_4") + +runfunc(html_it, rundir="src") +compare("gold_omit_4", "html_omit_4", size_within=10, file_pattern="*.html") +clean("html_omit_4") diff --git a/test/farm/html/run_omit_5.py b/test/farm/html/run_omit_5.py new file mode 100644 index 0000000..bd0fc9e --- /dev/null +++ b/test/farm/html/run_omit_5.py @@ -0,0 +1,12 @@ +def html_it(): + """Run coverage and make an HTML report for main.""" + import coverage + cov = coverage.coverage(config_file="omit5.ini") + cov.start() + import main + cov.stop() + cov.html_report() + +runfunc(html_it, rundir="src") +compare("gold_omit_5", "html_omit_5", size_within=10, file_pattern="*.html") +clean("html_omit_5") diff --git a/test/farm/html/run_tabbed.py b/test/farm/html/run_tabbed.py index f28e0c3..3076b4e 100644 --- a/test/farm/html/run_tabbed.py +++ b/test/farm/html/run_tabbed.py @@ -17,7 +17,7 @@ contains("html_tabbed/tabbed.html", "<span class='nam'>x</span><span class='op'>:</span>" " " " " - "<span class='com'># look nice</span>" + "<span class='com'># look nice</span>" ) doesnt_contain("html_tabbed/tabbed.html", "\t") diff --git a/test/farm/html/src/b.py b/test/farm/html/src/b.py index f5d051c..dffdd50 100644 --- a/test/farm/html/src/b.py +++ b/test/farm/html/src/b.py @@ -13,7 +13,7 @@ def two(x): # A missed else that branches to "exit" if x: a = 5 - + two(1) def three_way(): diff --git a/test/farm/html/src/coverage.xml b/test/farm/html/src/coverage.xml new file mode 100644 index 0000000..bc51732 --- /dev/null +++ b/test/farm/html/src/coverage.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" ?>
+<!DOCTYPE coverage
+ SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
+<coverage branch-rate="0.0" line-rate="0.666666666667" timestamp="1263087779313" version="3.3a1">
+ <!-- Generated by coverage.py: http://nedbatchelder.com/code/coverage -->
+ <packages>
+ <package branch-rate="0.0" complexity="0.0" line-rate="0.666666666667" name=".">
+ <classes>
+ <class branch-rate="0.0" complexity="0.0" filename="a.py" line-rate="0.666666666667" name="a">
+ <methods/>
+ <lines>
+ <line hits="1" number="3"/>
+ <line hits="1" number="5"/>
+ <line hits="0" number="7"/>
+ </lines>
+ </class>
+ </classes>
+ </package>
+ </packages>
+</coverage>
diff --git a/test/farm/html/src/m1.py b/test/farm/html/src/m1.py new file mode 100644 index 0000000..927e1f6 --- /dev/null +++ b/test/farm/html/src/m1.py @@ -0,0 +1,2 @@ +m1a = 1 +m1b = 2 diff --git a/test/farm/html/src/m2.py b/test/farm/html/src/m2.py new file mode 100644 index 0000000..ffddf6c --- /dev/null +++ b/test/farm/html/src/m2.py @@ -0,0 +1,2 @@ +m2a = 1 +m2b = 2 diff --git a/test/farm/html/src/m3.py b/test/farm/html/src/m3.py new file mode 100644 index 0000000..395d7d2 --- /dev/null +++ b/test/farm/html/src/m3.py @@ -0,0 +1,2 @@ +m3a = 1 +m3b = 2 diff --git a/test/farm/html/src/main.py b/test/farm/html/src/main.py new file mode 100644 index 0000000..ce89446 --- /dev/null +++ b/test/farm/html/src/main.py @@ -0,0 +1,10 @@ +import m1 +import m2 +import m3 + +a = 5 +b = 6 + +assert m1.m1a == 1 +assert m2.m2a == 1 +assert m3.m3a == 1 diff --git a/test/farm/html/src/omit4.ini b/test/farm/html/src/omit4.ini new file mode 100644 index 0000000..95f62a1 --- /dev/null +++ b/test/farm/html/src/omit4.ini @@ -0,0 +1,2 @@ +[report] +omit = m2 diff --git a/test/farm/html/src/omit5.ini b/test/farm/html/src/omit5.ini new file mode 100644 index 0000000..70ef491 --- /dev/null +++ b/test/farm/html/src/omit5.ini @@ -0,0 +1,8 @@ +[report] +omit = + fooey + gooey, m2, kablooey + m3, helloworld + +[html] +directory = ../html_omit_5 diff --git a/test/farm/html/src/run_a_xml_2.ini b/test/farm/html/src/run_a_xml_2.ini new file mode 100644 index 0000000..8d28f97 --- /dev/null +++ b/test/farm/html/src/run_a_xml_2.ini @@ -0,0 +1,3 @@ +# Put all the XML output in xml_2 +[xml] +output = ../xml_2/coverage.xml diff --git a/test/farm/html/src/tabbed.py b/test/farm/html/src/tabbed.py index bc6bb45..4c39caf 100644 --- a/test/farm/html/src/tabbed.py +++ b/test/farm/html/src/tabbed.py @@ -3,6 +3,6 @@ x = 1 if x: a = "Tabbed" # Aligned comments if x: # look nice - b = "No spaces" # when they + b = "No spaces" # when they c = "Done" # line up. diff --git a/test/farm/html/src/x.py b/test/farm/html/src/x.py deleted file mode 100644 index 9e71aeb..0000000 --- a/test/farm/html/src/x.py +++ /dev/null @@ -1,7 +0,0 @@ -# A test file for HTML reporting by coverage. - -if 1 < 2: - # Needed a < to look at HTML entities. - a = 3 -else: - a = 4 diff --git a/test/osinfo.py b/test/osinfo.py index 8bed2af..04855fe 100644 --- a/test/osinfo.py +++ b/test/osinfo.py @@ -2,7 +2,7 @@ import sys -if sys.hexversion >= 0x02050000 and sys.platform == 'win32': +if sys.version_info >= (2, 5) and sys.platform == 'win32': # Windows implementation def process_ram(): """How much RAM is this process using? (Windows)""" diff --git a/test/stress_phystoken.txt b/test/stress_phystoken.tok index 7e2f285..8d1b6be 100644 --- a/test/stress_phystoken.txt +++ b/test/stress_phystoken.tok @@ -1,6 +1,6 @@ # Here's some random Python so that test_tokenize_myself will have some -# stressful stuff to try. This file is .txt instead of .py so pylint won't -# complain about it. +# stressful stuff to try. This file is .tok instead of .py so pylint won't +# complain about it, check_eol won't look at it, etc. first_back = """\ hey there! @@ -15,6 +15,7 @@ lots_of_back = """\ hey \ there """ +# This next line is supposed to have trailing whitespace: fake_back = """\ ouch """ @@ -40,7 +41,7 @@ class C(object): cont1 = "one line of text" + \ "another line of text" -a_long_string = +a_long_string = \ "part 1" \ "2" \ "3 is longer" diff --git a/test/stress_phystoken_dos.tok b/test/stress_phystoken_dos.tok new file mode 100644 index 0000000..b08fd70 --- /dev/null +++ b/test/stress_phystoken_dos.tok @@ -0,0 +1,52 @@ +# Here's some random Python so that test_tokenize_myself will have some
+# stressful stuff to try. This file is .tok instead of .py so pylint won't
+# complain about it, check_eol won't look at it, etc.
+
+first_back = """\
+hey there!
+"""
+
+other_back = """
+hey \
+there
+"""
+
+lots_of_back = """\
+hey \
+there
+"""
+# This next line is supposed to have trailing whitespace:
+fake_back = """\
+ouch
+"""
+
+# Lots of difficulty happens with code like:
+#
+# fake_back = """\
+# ouch
+# """
+#
+# Ugh, the edge cases...
+
+# What about a comment like this\
+"what's this string doing here?"
+
+class C(object):
+ def there():
+ this = 5 + \
+ 7
+ that = \
+ "a continued line"
+
+cont1 = "one line of text" + \
+ "another line of text"
+
+a_long_string = \
+ "part 1" \
+ "2" \
+ "3 is longer"
+
+def hello():
+ print("Hello world!")
+
+hello()
diff --git a/test/test_api.py b/test/test_api.py index 2552d11..1f0ad83 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -28,8 +28,8 @@ class ApiTest(CoverageTest): # Import the python file, executing it. coverage.start() - self.import_module("mycode") - coverage.stop() + self.import_module("mycode") # pragma: recursive coverage + coverage.stop() # pragma: recursive coverage _, statements, missing, missingtext = coverage.analysis("mycode.py") self.assertEqual(statements, [1,2,3,4,5]) @@ -52,8 +52,8 @@ class ApiTest(CoverageTest): # Import the python file, executing it. coverage.start() - self.import_module(modname) - coverage.stop() + self.import_module(modname) # pragma: recursive coverage + coverage.stop() # pragma: recursive coverage def testReport(self): self.doReportWork("mycode2") @@ -81,7 +81,7 @@ class ApiTest(CoverageTest): self.doReportWork("mycode4") coverage.report() rpt = re.sub(r"\s+", " ", self.stdout()) - self.assert_("mycode4 7 4 57% 4-6" in rpt) + self.assertTrue("mycode4 7 4 57% 4-6" in rpt) def testUnexecutedFile(self): cov = coverage.coverage() @@ -100,8 +100,8 @@ class ApiTest(CoverageTest): # Import the python file, executing it. cov.start() - self.import_module("mycode") - cov.stop() + self.import_module("mycode") # pragma: recursive coverage + cov.stop() # pragma: recursive coverage _, statements, missing, _ = cov.analysis("not_run.py") self.assertEqual(statements, [1]) @@ -121,8 +121,8 @@ class ApiTest(CoverageTest): # Import the python file, executing it. cov = coverage.coverage() cov.start() - self.import_module("mymain") - cov.stop() + self.import_module("mymain") # pragma: recursive coverage + cov.stop() # pragma: recursive coverage filename, _, _, _ = cov.analysis("mymain.py") self.assertEqual(os.path.basename(filename), "mymain.py") @@ -138,8 +138,8 @@ class ApiTest(CoverageTest): # already. cov = coverage.coverage() cov.start() - self.import_module("mymain") - cov.stop() + self.import_module("mymain") # pragma: recursive coverage + cov.stop() # pragma: recursive coverage filename, _, _, _ = cov.analysis("mymain.py") self.assertEqual(os.path.basename(filename), "mymain.py") @@ -164,10 +164,10 @@ class ApiTest(CoverageTest): # Measure without the stdlib. cov1 = coverage.coverage() - self.assertEqual(cov1.cover_pylib, False) + self.assertEqual(cov1.config.cover_pylib, False) cov1.start() - self.import_module("mymain") - cov1.stop() + self.import_module("mymain") # pragma: recursive coverage + cov1.stop() # pragma: recursive coverage # some statements were marked executed in mymain.py _, statements, missing, _ = cov1.analysis("mymain.py") @@ -179,8 +179,8 @@ class ApiTest(CoverageTest): # Measure with the stdlib. cov2 = coverage.coverage(cover_pylib=True) cov2.start() - self.import_module("mymain") - cov2.stop() + self.import_module("mymain") # pragma: recursive coverage + cov2.stop() # pragma: recursive coverage # some statements were marked executed in mymain.py _, statements, missing, _ = cov2.analysis("mymain.py") @@ -210,8 +210,8 @@ class ApiTest(CoverageTest): self.assertSameElements(os.listdir("."), ["datatest1.py"]) cov = coverage.coverage() cov.start() - self.import_module("datatest1") - cov.stop() + self.import_module("datatest1") # pragma: recursive coverage + cov.stop() # pragma: recursive coverage cov.save() self.assertSameElements(os.listdir("."), ["datatest1.py", "datatest1.pyc", ".coverage"]) @@ -225,8 +225,8 @@ class ApiTest(CoverageTest): self.assertSameElements(os.listdir("."), ["datatest2.py"]) cov = coverage.coverage(data_file="cov.data") cov.start() - self.import_module("datatest2") - cov.stop() + self.import_module("datatest2") # pragma: recursive coverage + cov.stop() # pragma: recursive coverage cov.save() self.assertSameElements(os.listdir("."), ["datatest2.py", "datatest2.pyc", "cov.data"]) @@ -238,14 +238,34 @@ class ApiTest(CoverageTest): """) self.assertSameElements(os.listdir("."), ["datatest3.py"]) - cov = coverage.coverage(data_file="cov.data", data_suffix=".14") + cov = coverage.coverage(data_file="cov.data", data_suffix="14") cov.start() - self.import_module("datatest3") - cov.stop() + self.import_module("datatest3") # pragma: recursive coverage + cov.stop() # pragma: recursive coverage cov.save() self.assertSameElements(os.listdir("."), ["datatest3.py", "datatest3.pyc", "cov.data.14"]) + def testDatafileFromRcFile(self): + # You can specify the data file name in the .coveragerc file + self.make_file("datatest4.py", """\ + fooey = 17 + """) + self.make_file(".coveragerc", """\ + [run] + data_file = mydata.dat + """) + + self.assertSameElements(os.listdir("."), + ["datatest4.py", ".coveragerc"]) + cov = coverage.coverage() + cov.start() + self.import_module("datatest4") # pragma: recursive coverage + cov.stop() # pragma: recursive coverage + cov.save() + self.assertSameElements(os.listdir("."), + ["datatest4.py", "datatest4.pyc", ".coveragerc", "mydata.dat"]) + def testEmptyReporting(self): # Used to be you'd get an exception reporting on nothing... cov = coverage.coverage() diff --git a/test/test_arcs.py b/test/test_arcs.py index 45ab27e..5698ca5 100644 --- a/test/test_arcs.py +++ b/test/test_arcs.py @@ -212,7 +212,7 @@ class LoopArcTest(CoverageTest): ) # With "while True", 2.x thinks it's computation, 3.x thinks it's # constant. - if sys.hexversion >= 0x03000000: + if sys.version_info >= (3, 0): arcz = ".1 12 23 34 45 36 63 57 27 7." else: arcz = ".1 12 23 34 45 36 62 57 27 7." @@ -229,6 +229,33 @@ class LoopArcTest(CoverageTest): arcz_missing="27" # while loop never exits naturally. ) + def test_for_if_else_for(self): + self.check_coverage("""\ + def branches_2(l): + if l: + for e in l: + a = 4 + else: + a = 6 + + def branches_3(l): + for x in l: + if x: + for e in l: + a = 12 + else: + a = 14 + + branches_2([0,1]) + branches_3([0,1]) + """, + arcz= + ".1 18 8G GH H. " + ".2 23 34 43 26 3. 6. " + ".9 9A 9. AB BC CB B9 AE E9", + arcz_missing="26 6." + ) + class ExceptionArcTest(CoverageTest): """Arc-measuring tests involving exception handling.""" @@ -387,7 +414,7 @@ class ExceptionArcTest(CoverageTest): arcz=".1 12 23 34 3D 45 56 67 68 7A 8A A3 AB AD BC CD D.", arcz_missing="3D AB BC CD", arcz_unpredicted="") - if sys.hexversion >= 0x02050000: + if sys.version_info >= (2, 5): # Try-except-finally was new in 2.5 def test_except_finally(self): self.check_coverage("""\ diff --git a/test/test_cmdline.py b/test/test_cmdline.py index 258a08a..c530f89 100644 --- a/test/test_cmdline.py +++ b/test/test_cmdline.py @@ -1,8 +1,10 @@ """Test cmdline.py for coverage.""" -import os, re, shlex, sys, textwrap, unittest +import os, pprint, re, shlex, sys, textwrap, unittest import mock import coverage +import coverage.cmdline +from coverage.misc import ExceptionDuringRun sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k from coveragetest import CoverageTest, OK, ERR @@ -14,7 +16,7 @@ class CmdLineTest(CoverageTest): run_in_temp_dir = False INIT_LOAD = """\ - .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None) + .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True) .load()\n""" def model_object(self): @@ -47,14 +49,24 @@ class CmdLineTest(CoverageTest): m2 = self.model_object() code_obj = compile(code, "<code>", "exec") eval(code_obj, globals(), { 'm2': m2 }) - self.assertEqual(m1.method_calls, m2.method_calls) + self.assert_same_method_calls(m1, m2) def cmd_executes_same(self, args1, args2): """Assert that the `args1` executes the same as `args2`.""" m1, r1 = self.mock_command_line(args1) m2, r2 = self.mock_command_line(args2) self.assertEqual(r1, r2) - self.assertEqual(m1.method_calls, m2.method_calls) + self.assert_same_method_calls(m1, m2) + + def assert_same_method_calls(self, m1, m2): + """Assert that `m1.method_calls` and `m2.method_calls` are the same.""" + # Use a real equality comparison, but if it fails, use a nicer assert + # so we can tell what's going on. We have to use the real == first due + # to CmdOptionParser.__eq__ + if m1.method_calls != m2.method_calls: + pp1 = pprint.pformat(m1.method_calls) + pp2 = pprint.pformat(m2.method_calls) + self.assertMultiLineEqual(pp1+'\n', pp2+'\n') def cmd_help(self, args, help_msg=None, topic=None, ret=ERR): """Run a command line, and check that it prints the right help. @@ -83,7 +95,7 @@ class ClassicCmdLineTest(CmdLineTest): def testErase(self): # coverage -e self.cmd_executes("-e", """\ - .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None) + .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True) .erase() """) self.cmd_executes_same("-e", "--erase") @@ -93,7 +105,7 @@ class ClassicCmdLineTest(CmdLineTest): # -x calls coverage.load first. self.cmd_executes("-x foo.py", """\ - .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None) + .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True) .load() .start() .run_python_file('foo.py', ['foo.py']) @@ -102,7 +114,7 @@ class ClassicCmdLineTest(CmdLineTest): """) # -e -x calls coverage.erase first. self.cmd_executes("-e -x foo.py", """\ - .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None) + .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True) .erase() .start() .run_python_file('foo.py', ['foo.py']) @@ -111,7 +123,7 @@ class ClassicCmdLineTest(CmdLineTest): """) # --timid sets a flag, and program arguments get passed through. self.cmd_executes("-x --timid foo.py abc 123", """\ - .coverage(cover_pylib=None, data_suffix=False, timid=True, branch=None) + .coverage(cover_pylib=None, data_suffix=None, timid=True, branch=None, config_file=True) .load() .start() .run_python_file('foo.py', ['foo.py', 'abc', '123']) @@ -120,7 +132,7 @@ class ClassicCmdLineTest(CmdLineTest): """) # -L sets a flag, and flags for the program don't confuse us. self.cmd_executes("-x -p -L foo.py -a -b", """\ - .coverage(cover_pylib=True, data_suffix=True, timid=None, branch=None) + .coverage(cover_pylib=True, data_suffix=True, timid=None, branch=None, config_file=True) .load() .start() .run_python_file('foo.py', ['foo.py', '-a', '-b']) @@ -137,7 +149,7 @@ class ClassicCmdLineTest(CmdLineTest): def testCombine(self): # coverage -c self.cmd_executes("-c", """\ - .coverage(cover_pylib=None, data_suffix=False, timid=None, branch=None) + .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True) .load() .combine() .save() @@ -325,6 +337,33 @@ class ClassicCmdLineTest(CmdLineTest): self.cmd_help("-z", "no such option: -z") +class FakeCoverageForDebugData(object): + """Just enough of a fake coverage package for the 'debug data' tests.""" + def __init__(self, summary): + self._summary = summary + self.filename = "FILENAME" + self.data = self + + # package members + def coverage(self, *unused_args, **unused_kwargs): + """The coverage class in the package.""" + return self + + # coverage methods + def load(self): + """Fake coverage().load()""" + pass + + # data methods + def has_arcs(self): + """Fake coverage().data.has_arcs()""" + return False + + def summary(self, fullpath): # pylint: disable-msg=W0613 + """Fake coverage().data.summary()""" + return self._summary + + class NewCmdLineTest(CmdLineTest): """Tests of the coverage.py command line.""" @@ -344,6 +383,31 @@ class NewCmdLineTest(CmdLineTest): self.cmd_help("debug", "What information would you like: data, sys?") self.cmd_help("debug foo", "Don't know what you mean by 'foo'") + def testDebugData(self): + fake = FakeCoverageForDebugData({ + 'file1.py': 17, 'file2.py': 23, + }) + self.command_line("debug data", _covpkg=fake) + self.assertMultiLineEqual(self.stdout(), textwrap.dedent("""\ + -- data --------------------------------------- + path: FILENAME + has_arcs: False + + 2 files: + file1.py: 17 lines + file2.py: 23 lines + """)) + + def testDebugDataWithNoData(self): + fake = FakeCoverageForDebugData({}) + self.command_line("debug data", _covpkg=fake) + self.assertMultiLineEqual(self.stdout(), textwrap.dedent("""\ + -- data --------------------------------------- + path: FILENAME + has_arcs: False + No data collected + """)) + def testDebugSys(self): self.command_line("debug sys") out = self.stdout() @@ -387,6 +451,22 @@ class NewCmdLineTest(CmdLineTest): self.cmd_executes_same("run -L f.py", "-e -x -L f.py") self.cmd_executes_same("run --timid f.py", "-e -x --timid f.py") self.cmd_executes_same("run", "-x") + self.cmd_executes("run --branch foo.py", """\ + .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=True, config_file=True) + .erase() + .start() + .run_python_file('foo.py', ['foo.py']) + .stop() + .save() + """) + self.cmd_executes("run --rcfile=myrc.rc foo.py", """\ + .coverage(cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file="myrc.rc") + .erase() + .start() + .run_python_file('foo.py', ['foo.py']) + .stop() + .save() + """) def testXml(self): # coverage xml [-i] [--omit DIR,...] [FILE1 FILE2 ...] @@ -404,7 +484,7 @@ class NewCmdLineTest(CmdLineTest): """) self.cmd_executes("xml -o -", self.INIT_LOAD + """\ .xml_report(ignore_errors=None, omit_prefixes=None, morfs=[], - outfile=None) + outfile="-") """) self.cmd_executes("xml --omit fooey", self.INIT_LOAD + """\ .xml_report(ignore_errors=None, omit_prefixes=["fooey"], morfs=[], @@ -459,5 +539,62 @@ class CmdLineStdoutTest(CmdLineTest): assert "help" in out +class CmdMainTest(CoverageTest): + """Tests of coverage.cmdline.main(), using mocking for isolation.""" + + class CoverageScriptStub(object): + """A stub for coverage.cmdline.CoverageScript, used by CmdMainTest.""" + + def command_line(self, argv): + """Stub for command_line, the arg determines what it will do.""" + if argv[0] == 'hello': + print("Hello, world!") + elif argv[0] == 'raise': + try: + raise Exception("oh noes!") + except: + raise ExceptionDuringRun(*sys.exc_info()) + elif argv[0] == 'internalraise': + raise ValueError("coverage is broken") + elif argv[0] == 'exit': + sys.exit(23) + else: + raise AssertionError("Bad CoverageScriptStub: %r"% (argv,)) + return 0 + + def setUp(self): + super(CmdMainTest, self).setUp() + self.old_CoverageScript = coverage.cmdline.CoverageScript + coverage.cmdline.CoverageScript = self.CoverageScriptStub + + def tearDown(self): + coverage.cmdline.CoverageScript = self.old_CoverageScript + super(CmdMainTest, self).tearDown() + + def test_normal(self): + ret = coverage.cmdline.main(['hello']) + self.assertEqual(ret, 0) + self.assertEqual(self.stdout(), "Hello, world!\n") + + def test_raise(self): + ret = coverage.cmdline.main(['raise']) + self.assertEqual(ret, 1) + self.assertEqual(self.stdout(), "") + err = self.stderr().split('\n') + self.assertEqual(err[0], 'Traceback (most recent call last):') + self.assertEqual(err[-3], ' raise Exception("oh noes!")') + self.assertEqual(err[-2], 'Exception: oh noes!') + + def test_internalraise(self): + self.assertRaisesRegexp(ValueError, + "coverage is broken", + coverage.cmdline.main, ['internalraise'] + ) + + def test_exit(self): + ret = coverage.cmdline.main(['exit']) + self.assertEqual(ret, 23) + + if __name__ == '__main__': unittest.main() diff --git a/test/test_codeunit.py b/test/test_codeunit.py index ad07382..35387ba 100644 --- a/test/test_codeunit.py +++ b/test/test_codeunit.py @@ -64,10 +64,10 @@ class CodeUnitTest(CoverageTest): self.assertEqual(cu[2].source_file().read(), "# cfile.py\n") def test_comparison(self): - acu = code_unit_factory("aa/afile.py", FileLocator()) - acu2 = code_unit_factory("aa/afile.py", FileLocator()) - zcu = code_unit_factory("aa/zfile.py", FileLocator()) - bcu = code_unit_factory("aa/bb/bfile.py", FileLocator()) + acu = code_unit_factory("aa/afile.py", FileLocator())[0] + acu2 = code_unit_factory("aa/afile.py", FileLocator())[0] + zcu = code_unit_factory("aa/zfile.py", FileLocator())[0] + bcu = code_unit_factory("aa/bb/bfile.py", FileLocator())[0] assert acu == acu2 and acu <= acu2 and acu >= acu2 assert acu < zcu and acu <= zcu and acu != zcu assert zcu > acu and zcu >= acu and zcu != acu diff --git a/test/test_config.py b/test/test_config.py new file mode 100644 index 0000000..f4bd65b --- /dev/null +++ b/test/test_config.py @@ -0,0 +1,145 @@ +"""Test the config file handling for coverage.py""" + +import os, sys +import coverage + +sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k +from coveragetest import CoverageTest + + +class ConfigTest(CoverageTest): + """Tests of the different sources of configuration settings.""" + + def test_default_config(self): + # Just constructing a coverage() object gets the right defaults. + cov = coverage.coverage() + self.assertFalse(cov.config.timid) + self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, ".coverage") + + def test_arguments(self): + # Arguments to the constructor are applied to the configuation. + cov = coverage.coverage(timid=True, data_file="fooey.dat") + self.assertTrue(cov.config.timid) + self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, "fooey.dat") + + def test_config_file(self): + # A .coveragerc file will be read into the configuration. + self.make_file(".coveragerc", """\ + # This is just a bogus .rc file for testing. + [run] + timid = True + data_file = .hello_kitty.data + """) + cov = coverage.coverage() + self.assertTrue(cov.config.timid) + self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, ".hello_kitty.data") + + def test_named_config_file(self): + # You can name the config file what you like. + self.make_file("my_cov.ini", """\ + [run] + timid = True + ; I wouldn't really use this as a data file... + data_file = delete.me + """) + cov = coverage.coverage(config_file="my_cov.ini") + self.assertTrue(cov.config.timid) + self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, "delete.me") + + def test_ignored_config_file(self): + # You can disable reading the .coveragerc file. + self.make_file(".coveragerc", """\ + [run] + timid = True + data_file = delete.me + """) + cov = coverage.coverage(config_file=False) + self.assertFalse(cov.config.timid) + self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, ".coverage") + + def test_config_file_then_args(self): + # The arguments override the .coveragerc file. + self.make_file(".coveragerc", """\ + [run] + timid = True + data_file = weirdo.file + """) + cov = coverage.coverage(timid=False, data_file=".mycov") + self.assertFalse(cov.config.timid) + self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, ".mycov") + + def test_data_file_from_environment(self): + # There's an environment variable for the data_file. + self.make_file(".coveragerc", """\ + [run] + timid = True + data_file = weirdo.file + """) + self.set_environ("COVERAGE_FILE", "fromenv.dat") + cov = coverage.coverage() + self.assertEqual(cov.config.data_file, "fromenv.dat") + # But the constructor args override the env var. + cov = coverage.coverage(data_file="fromarg.dat") + self.assertEqual(cov.config.data_file, "fromarg.dat") + + +class ConfigFileTest(CoverageTest): + """Tests of the config file settings in particular.""" + + def test_config_file_settings(self): + # This sample file tries to use lots of variation of syntax... + self.make_file(".coveragerc", """\ + # This is a settings file for coverage.py + [run] + timid = yes + data_file = something_or_other.dat + branch = 1 + cover_pylib = TRUE + parallel = on + + [report] + ; these settings affect reporting. + exclude_lines = + if 0: + + pragma:?\\s+no cover + another_tab + + ignore_errors = TRUE + omit = + one, another, some_more, + yet_more + + [html] + + directory = c:\\tricky\\dir.somewhere + + [xml] + output=mycov.xml + + """) + cov = coverage.coverage() + + self.assertTrue(cov.config.timid) + self.assertEqual(cov.config.data_file, "something_or_other.dat") + self.assertTrue(cov.config.branch) + self.assertTrue(cov.config.cover_pylib) + self.assertTrue(cov.config.parallel) + + self.assertEqual(cov.get_exclude_list(), + ["if 0:", "pragma:?\s+no cover", "another_tab"] + ) + self.assertTrue(cov.config.ignore_errors) + self.assertEqual(cov.config.omit_prefixes, + ["one", "another", "some_more", "yet_more"] + ) + + self.assertEqual(cov.config.html_dir, r"c:\tricky\dir.somewhere") + + self.assertEqual(cov.config.xml_output, "mycov.xml") diff --git a/test/test_coverage.py b/test/test_coverage.py index c1a7248..e0afd31 100644 --- a/test/test_coverage.py +++ b/test/test_coverage.py @@ -1,5 +1,4 @@ """Tests for Coverage.""" -# Copyright 2004-2009, Ned Batchelder # http://nedbatchelder.com/code/coverage import os, sys, unittest @@ -13,6 +12,86 @@ sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k from coveragetest import CoverageTest +class TestCoverageTest(CoverageTest): + """Make sure our complex self.check_coverage method works.""" + + def test_successful_coverage(self): + # The simplest run possible. + self.check_coverage("""\ + a = 1 + 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 + if a == 2: + a = 3 + """, + [1,2,3], + missing="3", + ) + # You can specify a list of possible missing lines. + self.check_coverage("""\ + a = 1 + if a == 2: + a = 3 + """, + [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. + self.assertRaisesRegexp(AssertionError, + r"\[1, 2] != \[1]", + self.check_coverage, """\ + a = 1 + b = 2 + """, + [1] + ) + # If the list of lines possibilities is wrong, the msg shows right. + self.assertRaisesRegexp(AssertionError, + r"None of the lines choices matched \[1, 2]", + self.check_coverage, """\ + a = 1 + b = 2 + """, + ([1], [2]) + ) + # If the missing lines are wrong, the message shows right and wrong. + self.assertRaisesRegexp(AssertionError, + r"'3' != '37'", + self.check_coverage, """\ + a = 1 + if a == 2: + a = 3 + """, + [1,2,3], + missing="37", + ) + # If the missing lines possibilities are wrong, the msg shows right. + self.assertRaisesRegexp(AssertionError, + r"None of the missing choices matched '3'", + self.check_coverage, """\ + a = 1 + if a == 2: + a = 3 + """, + [1,2,3], + missing=("37", "4-10"), + ) + + class BasicCoverageTest(CoverageTest): """The simplest tests, for quick smoke testing of fundamental changes.""" @@ -212,7 +291,7 @@ class SimpleStatementTest(CoverageTest): """, [1,2,3,6,9], "") - if sys.hexversion < 0x03000000: # Print statement is gone in Py3k. + if sys.version_info < (3, 0): # Print statement is gone in Py3k. def testPrint(self): self.check_coverage("""\ print "hello, world!" @@ -403,7 +482,7 @@ class SimpleStatementTest(CoverageTest): """, [1,2,3,4,5], "") - if sys.hexversion < 0x03000000: + if sys.version_info < (3, 0): # In Python 2.x, exec is a statement. def testExec(self): self.check_coverage("""\ @@ -1038,6 +1117,18 @@ class CompoundStatementTest(CoverageTest): class ExcludeTest(CoverageTest): """Tests of the exclusion feature to mark lines as not covered.""" + def testDefault(self): + # A number of forms of pragma comment are accepted. + self.check_coverage("""\ + a = 1 + b = 2 # pragma: no cover + c = 3 + d = 4 #pragma NOCOVER + e = 5 + """, + [1,3,5] + ) + def testSimple(self): self.check_coverage("""\ a = 1; b = 2 @@ -1393,7 +1484,7 @@ class ExcludeTest(CoverageTest): [8,9], "", ['#pragma: NO COVER']) -if sys.hexversion >= 0x020400f0: +if sys.version_info >= (2, 4): class Py24Test(CoverageTest): """Tests of new syntax in Python 2.4.""" @@ -1464,7 +1555,7 @@ if sys.hexversion >= 0x020400f0: [1,2,3,4,5,7,8,9,10,11,12,14, 17,19,21, 24,26]), "") -if sys.hexversion >= 0x020500f0: +if sys.version_info >= (2, 5): class Py25Test(CoverageTest): """Tests of new syntax in Python 2.5.""" @@ -1585,96 +1676,8 @@ class ModuleTest(CoverageTest): coverage.coverage() -class ProcessTest(CoverageTest): - """Tests of the per-process behavior of coverage.py.""" - - def testSaveOnExit(self): - self.make_file("mycode.py", """\ - h = "Hello" - w = "world" - """) - - self.assert_(not os.path.exists(".coverage")) - self.run_command("coverage -x mycode.py") - self.assert_(os.path.exists(".coverage")) - - def testEnvironment(self): - # Checks that we can import modules from the test directory at all! - self.make_file("mycode.py", """\ - import covmod1 - import covmodzip1 - a = 1 - print ('done') - """) - - self.assert_(not os.path.exists(".coverage")) - out = self.run_command("coverage -x mycode.py") - self.assert_(os.path.exists(".coverage")) - self.assertEqual(out, 'done\n') - - def testCombineParallelData(self): - self.make_file("b_or_c.py", """\ - import sys - a = 1 - if sys.argv[1] == 'b': - b = 1 - else: - c = 1 - d = 1 - print ('done') - """) - - out = self.run_command("coverage -x -p b_or_c.py b") - self.assertEqual(out, 'done\n') - self.assert_(not os.path.exists(".coverage")) - - out = self.run_command("coverage -x -p b_or_c.py c") - self.assertEqual(out, 'done\n') - self.assert_(not os.path.exists(".coverage")) - - # After two -p runs, there should be two .coverage.machine.123 files. - self.assertEqual( - len([f for f in os.listdir('.') if f.startswith('.coverage.')]), - 2) - - # Combine the parallel coverage data files into .coverage . - self.run_command("coverage -c") - self.assert_(os.path.exists(".coverage")) - - # Read the coverage file and see that b_or_c.py has all 7 lines - # executed. - data = coverage.CoverageData() - data.read_file(".coverage") - self.assertEqual(data.summary()['b_or_c.py'], 7) - - def test_missing_source_file(self): - # Check what happens if the source is missing when reporting happens. - self.make_file("fleeting.py", """\ - s = 'goodbye, cruel world!' - """) - - self.run_command("coverage run fleeting.py") - os.remove("fleeting.py") - out = self.run_command("coverage html -d htmlcov") - self.assertRegexpMatches(out, "No source for code: '.*fleeting.py'") - self.assert_("Traceback" not in out) - - # It happens that the code paths are different for *.py and other - # files, so try again with no extension. - self.make_file("fleeting", """\ - s = 'goodbye, cruel world!' - """) - - self.run_command("coverage run fleeting") - os.remove("fleeting") - out = self.run_command("coverage html -d htmlcov") - self.assertRegexpMatches(out, "No source for code: '.*fleeting'") - self.assert_("Traceback" not in out) - - def test_running_missing_file(self): - out = self.run_command("coverage run xyzzy.py") - self.assertRegexpMatches(out, "No file to run: .*xyzzy.py") - self.assert_("Traceback" not in out) +class ReportingTest(CoverageTest): + """Tests of some reporting behavior.""" def test_no_data_to_report_on_annotate(self): # Reporting with no data produces a nice message and no output dir. diff --git a/test/test_execfile.py b/test/test_execfile.py index 8c5e9a1..2f28a06 100644 --- a/test/test_execfile.py +++ b/test/test_execfile.py @@ -60,5 +60,17 @@ class RunTest(CoverageTest): run_python_file('nl.py', ['nl.py']) self.assertEqual(self.stdout(), "Hello, world!\n"*3) + def test_missing_final_newline(self): + # Make sure we can deal with a Python file with no final newline. + self.make_file("abrupt.py", """\ + if 1: + a = 1 + print("a is %r" % a) + #""") + abrupt = open("abrupt.py").read() + self.assertEqual(abrupt[-1], '#') + run_python_file("abrupt.py", ["abrupt.py"]) + self.assertEqual(self.stdout(), "a is 1\n") + def test_no_such_file(self): self.assertRaises(NoSource, run_python_file, "xyzzy.py", []) diff --git a/test/test_farm.py b/test/test_farm.py index de07541..405c68d 100644 --- a/test/test_farm.py +++ b/test/test_farm.py @@ -3,7 +3,7 @@ import difflib, filecmp, fnmatch, glob, os, re, shutil, sys sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k -from backtest import run_command, execfile # pylint: disable-msg=W0622 +from backtest import run_command, execfile # pylint: disable-msg=W0622 def test_farm(clean_only=False): @@ -75,10 +75,15 @@ class FarmTestCase(object): if self.dont_clean: glo['clean'] = self.noop + old_mods = dict(sys.modules) try: execfile(self.runpy, glo) finally: self.cd(cwd) + # Remove any new modules imported during the test run. This lets us + # import the same source files for more than one test. + for m in [m for m in sys.modules if m not in old_mods]: + del sys.modules[m] def run_fully(self): # pragma: no cover """Run as a full test case, with setUp and tearDown.""" @@ -290,7 +295,21 @@ class FarmTestCase(object): def clean(self, cleandir): """Clean `cleandir` by removing it and all its children completely.""" if os.path.exists(cleandir): - shutil.rmtree(cleandir) + # rmtree gives mysterious failures on Win7, so use an onerror + # function that tries to help diagnose the problem. Somehow, just + # having a function that prints and raises keeps the error from + # happening?? + shutil.rmtree(cleandir, onerror=self.rmtree_err) + + def rmtree_err(self, fn, path, exc): + """A stupid error handler that prints and raises. + + Somehow, this fixes the problem it was meant to diagnose. + + """ + print("Couldn't %r on %r due to %s" % (fn, path, exc)) + raise exc + def main(): # pragma: no cover """Command-line access to test_farm. diff --git a/test/test_oddball.py b/test/test_oddball.py index 05252ef..a40fb4c 100644 --- a/test/test_oddball.py +++ b/test/test_oddball.py @@ -92,7 +92,7 @@ class MemoryLeakTest(CoverageTest): self.check_coverage(code.replace("ITERS", "10000"), lines, "") ram_2 = osinfo.process_ram() ram_growth = (ram_2 - ram_1) - (ram_1 - ram_0) - self.assert_(ram_growth < 100000, "RAM grew by %d" % (ram_growth)) + self.assertTrue(ram_growth < 100000, "RAM grew by %d" % (ram_growth)) class PyexpatTest(CoverageTest): @@ -245,7 +245,7 @@ class ExceptionTest(CoverageTest): self.assertEqual(clean_lines, lines_expected) -if sys.hexversion > 0x02050000: +if sys.version_info >= (2, 5): class DoctestTest(CoverageTest): """Tests invoked with doctest should measure properly.""" diff --git a/test/test_phystokens.py b/test/test_phystokens.py index 6b16d68..0e77851 100644 --- a/test/test_phystokens.py +++ b/test/test_phystokens.py @@ -36,6 +36,7 @@ class PhysTokensTest(CoverageTest): tokenized += text + "\n" # source_token_lines doesn't preserve trailing spaces, so trim all that # before comparing. + source = source.replace('\r\n', '\n') source = re.sub("(?m)[ \t]+$", "", source) tokenized = re.sub("(?m)[ \t]+$", "", tokenized) self.assertMultiLineEqual(source, tokenized) @@ -75,5 +76,7 @@ class PhysTokensTest(CoverageTest): def test_stress(self): # Check the tokenization of a stress-test file. - stress = os.path.join(HERE, "stress_phystoken.txt") + stress = os.path.join(HERE, "stress_phystoken.tok") + self.check_file_tokenization(stress) + stress = os.path.join(HERE, "stress_phystoken_dos.tok") self.check_file_tokenization(stress) diff --git a/test/test_process.py b/test/test_process.py new file mode 100644 index 0000000..ce98a38 --- /dev/null +++ b/test/test_process.py @@ -0,0 +1,205 @@ +"""Tests for process behavior of coverage.py.""" + +import os, sys, textwrap +import coverage + +sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k +from coveragetest import CoverageTest + + +class ProcessTest(CoverageTest): + """Tests of the per-process behavior of coverage.py.""" + + def number_of_data_files(self): + """Return the number of coverage data files in this directory.""" + num = 0 + for f in os.listdir('.'): + if f.startswith('.coverage.') or f == '.coverage': + num += 1 + return num + + def testSaveOnExit(self): + self.make_file("mycode.py", """\ + h = "Hello" + w = "world" + """) + + self.assertFalse(os.path.exists(".coverage")) + self.run_command("coverage -x mycode.py") + self.assertTrue(os.path.exists(".coverage")) + + def testEnvironment(self): + # Checks that we can import modules from the test directory at all! + self.make_file("mycode.py", """\ + import covmod1 + import covmodzip1 + a = 1 + print ('done') + """) + + self.assertFalse(os.path.exists(".coverage")) + out = self.run_command("coverage -x mycode.py") + self.assertTrue(os.path.exists(".coverage")) + self.assertEqual(out, 'done\n') + + def testCombineParallelData(self): + self.make_file("b_or_c.py", """\ + import sys + a = 1 + if sys.argv[1] == 'b': + b = 1 + else: + c = 1 + d = 1 + print ('done') + """) + + out = self.run_command("coverage -x -p b_or_c.py b") + self.assertEqual(out, 'done\n') + self.assertFalse(os.path.exists(".coverage")) + + out = self.run_command("coverage -x -p b_or_c.py c") + self.assertEqual(out, 'done\n') + self.assertFalse(os.path.exists(".coverage")) + + # After two -p runs, there should be two .coverage.machine.123 files. + self.assertEqual(self.number_of_data_files(), 2) + + # Combine the parallel coverage data files into .coverage . + self.run_command("coverage -c") + self.assertTrue(os.path.exists(".coverage")) + + # After combining, there should be only the .coverage file. + self.assertEqual(self.number_of_data_files(), 1) + + # Read the coverage file and see that b_or_c.py has all 7 lines + # executed. + data = coverage.CoverageData() + data.read_file(".coverage") + self.assertEqual(data.summary()['b_or_c.py'], 7) + + def test_combine_with_rc(self): + self.make_file("b_or_c.py", """\ + import sys + a = 1 + if sys.argv[1] == 'b': + b = 1 + else: + c = 1 + d = 1 + print ('done') + """) + + self.make_file(".coveragerc", """\ + [run] + parallel = true + """) + + out = self.run_command("coverage run b_or_c.py b") + self.assertEqual(out, 'done\n') + self.assertFalse(os.path.exists(".coverage")) + + out = self.run_command("coverage run b_or_c.py c") + self.assertEqual(out, 'done\n') + self.assertFalse(os.path.exists(".coverage")) + + # After two runs, there should be two .coverage.machine.123 files. + self.assertEqual(self.number_of_data_files(), 2) + + # Combine the parallel coverage data files into .coverage . + self.run_command("coverage combine") + self.assertTrue(os.path.exists(".coverage")) + self.assertTrue(os.path.exists(".coveragerc")) + + # After combining, there should be only the .coverage file. + self.assertEqual(self.number_of_data_files(), 1) + + # Read the coverage file and see that b_or_c.py has all 7 lines + # executed. + data = coverage.CoverageData() + data.read_file(".coverage") + self.assertEqual(data.summary()['b_or_c.py'], 7) + + # Reporting should still work even with the .rc file + out = self.run_command("coverage report") + self.assertMultiLineEqual(out, textwrap.dedent("""\ + Name Stmts Exec Cover + ---------------------------- + b_or_c 7 7 100% + """)) + + def test_missing_source_file(self): + # Check what happens if the source is missing when reporting happens. + self.make_file("fleeting.py", """\ + s = 'goodbye, cruel world!' + """) + + self.run_command("coverage run fleeting.py") + os.remove("fleeting.py") + out = self.run_command("coverage html -d htmlcov") + self.assertRegexpMatches(out, "No source for code: '.*fleeting.py'") + self.assertFalse("Traceback" in out) + + # It happens that the code paths are different for *.py and other + # files, so try again with no extension. + self.make_file("fleeting", """\ + s = 'goodbye, cruel world!' + """) + + self.run_command("coverage run fleeting") + os.remove("fleeting") + status, out = self.run_command_status("coverage html -d htmlcov", 1) + self.assertRegexpMatches(out, "No source for code: '.*fleeting'") + self.assertFalse("Traceback" in out) + self.assertEqual(status, 1) + + def test_running_missing_file(self): + status, out = self.run_command_status("coverage run xyzzy.py", 1) + self.assertRegexpMatches(out, "No file to run: .*xyzzy.py") + self.assertFalse("Traceback" in out) + self.assertEqual(status, 1) + + def test_code_throws(self): + self.make_file("throw.py", """\ + def f1(): + raise Exception("hey!") + + def f2(): + f1() + + f2() + """) + + # The important thing is for "coverage run" and "python" to report the + # same traceback. + status, out = self.run_command_status("coverage run throw.py", 1) + out2 = self.run_command("python throw.py") + self.assertMultiLineEqual(out, out2) + + # But also make sure that the output is what we expect. + self.assertTrue('File "throw.py", line 5, in f2' in out) + self.assertTrue('raise Exception("hey!")' in out) + self.assertFalse('coverage' in out) + self.assertEqual(status, 1) + + def test_code_exits(self): + self.make_file("exit.py", """\ + import sys + def f1(): + print("about to exit..") + sys.exit(17) + + def f2(): + f1() + + f2() + """) + + # The important thing is for "coverage run" and "python" to have the + # same output. No traceback. + status, out = self.run_command_status("coverage run exit.py", 17) + status2, out2 = self.run_command_status("python exit.py", 17) + self.assertMultiLineEqual(out, out2) + self.assertMultiLineEqual(out, "about to exit..\n") + self.assertEqual(status, status2) + self.assertEqual(status, 17) diff --git a/test/test_summary.py b/test/test_summary.py index 0eec58c..d2f40ae 100644 --- a/test/test_summary.py +++ b/test/test_summary.py @@ -20,7 +20,7 @@ class SummaryTest(CoverageTest): def report_from_command(self, cmd): """Return the report from the `cmd`, with some convenience added.""" report = self.run_command(cmd).replace('\\', '/') - self.assert_("error" not in report.lower()) + self.assertFalse("error" in report.lower()) return report def line_count(self, report): @@ -46,10 +46,10 @@ class SummaryTest(CoverageTest): # --------------------------------------------------------------------- # TOTAL 8 8 100% - self.assert_("/coverage/__init__/" not in report) - self.assert_("/test/modules/covmod1 " in report) - self.assert_("/test/zipmods.zip/covmodzip1 " in report) - self.assert_("mycode " in report) + self.assertFalse("/coverage/__init__/" in report) + self.assertTrue("/test/modules/covmod1 " in report) + self.assertTrue("/test/zipmods.zip/covmodzip1 " in report) + self.assertTrue("mycode " in report) self.assertEqual(self.last_line_squeezed(report), "TOTAL 8 8 100%") def test_report_just_one(self): @@ -62,10 +62,10 @@ class SummaryTest(CoverageTest): # mycode 4 4 100% self.assertEqual(self.line_count(report), 3) - self.assert_("/coverage/" not in report) - self.assert_("/test/modules/covmod1 " not in report) - self.assert_("/test/zipmods.zip/covmodzip1 " not in report) - self.assert_("mycode " in report) + self.assertFalse("/coverage/" in report) + self.assertFalse("/test/modules/covmod1 " in report) + self.assertFalse("/test/zipmods.zip/covmodzip1 " in report) + self.assertTrue("mycode " in report) self.assertEqual(self.last_line_squeezed(report), "mycode 4 4 100%") def test_report_omitting(self): @@ -79,10 +79,10 @@ class SummaryTest(CoverageTest): # mycode 4 4 100% self.assertEqual(self.line_count(report), 3) - self.assert_("/coverage/" not in report) - self.assert_("/test/modules/covmod1 " not in report) - self.assert_("/test/zipmods.zip/covmodzip1 " not in report) - self.assert_("mycode " in report) + self.assertFalse("/coverage/" in report) + self.assertFalse("/test/modules/covmod1 " in report) + self.assertFalse("/test/zipmods.zip/covmodzip1 " in report) + self.assertTrue("mycode " in report) self.assertEqual(self.last_line_squeezed(report), "mycode 4 4 100%") def test_report_branches(self): @@ -102,6 +102,6 @@ class SummaryTest(CoverageTest): # mybranch 5 5 2 1 85% self.assertEqual(self.line_count(report), 3) - self.assert_("mybranch " in report) + self.assertTrue("mybranch " in report) self.assertEqual(self.last_line_squeezed(report), "mybranch 5 5 2 1 85%") diff --git a/test/test_testing.py b/test/test_testing.py index a239d14..5a72c55 100644 --- a/test/test_testing.py +++ b/test/test_testing.py @@ -76,3 +76,11 @@ class TestingTest(TestCase): self.assertRaisesRegexp, ZeroDivisionError, "XYZ", self.please_succeed ) + + def test_assert_true(self): + self.assertTrue(True) + self.assertRaises(AssertionError, self.assertTrue, False) + + def test_assert_false(self): + self.assertFalse(False) + self.assertRaises(AssertionError, self.assertFalse, True) |
