diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-02-02 11:15:11 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-02-02 11:15:11 -0500 |
commit | c19232a9d2be2bde30e446311f32e9dcdd5d4774 (patch) | |
tree | c2a9afb49cb74d9e041058c0275e1896dc0ecd0c /test/test_html.py | |
parent | c359cea1408c410a4c770debeddf3aed0abd43fe (diff) | |
download | python-coveragepy-git-c19232a9d2be2bde30e446311f32e9dcdd5d4774.tar.gz |
Move the test directory to tests to avoid conflicts with the stdlib test package.
--HG--
rename : test/__init__.py => tests/__init__.py
rename : test/backtest.py => tests/backtest.py
rename : test/backunittest.py => tests/backunittest.py
rename : test/coveragetest.py => tests/coveragetest.py
rename : test/covmodzip1.py => tests/covmodzip1.py
rename : test/eggsrc/egg1/__init__.py => tests/eggsrc/egg1/__init__.py
rename : test/eggsrc/egg1/egg1.py => tests/eggsrc/egg1/egg1.py
rename : test/eggsrc/setup.py => tests/eggsrc/setup.py
rename : test/farm/annotate/annotate_dir.py => tests/farm/annotate/annotate_dir.py
rename : test/farm/annotate/gold/white.py,cover => tests/farm/annotate/gold/white.py,cover
rename : test/farm/annotate/gold_anno_dir/a___init__.py,cover => tests/farm/annotate/gold_anno_dir/a___init__.py,cover
rename : test/farm/annotate/gold_anno_dir/a_a.py,cover => tests/farm/annotate/gold_anno_dir/a_a.py,cover
rename : test/farm/annotate/gold_anno_dir/b___init__.py,cover => tests/farm/annotate/gold_anno_dir/b___init__.py,cover
rename : test/farm/annotate/gold_anno_dir/b_b.py,cover => tests/farm/annotate/gold_anno_dir/b_b.py,cover
rename : test/farm/annotate/gold_anno_dir/multi.py,cover => tests/farm/annotate/gold_anno_dir/multi.py,cover
rename : test/farm/annotate/gold_multi/a/__init__.py,cover => tests/farm/annotate/gold_multi/a/__init__.py,cover
rename : test/farm/annotate/gold_multi/a/a.py,cover => tests/farm/annotate/gold_multi/a/a.py,cover
rename : test/farm/annotate/gold_multi/b/__init__.py,cover => tests/farm/annotate/gold_multi/b/__init__.py,cover
rename : test/farm/annotate/gold_multi/b/b.py,cover => tests/farm/annotate/gold_multi/b/b.py,cover
rename : test/farm/annotate/gold_multi/multi.py,cover => tests/farm/annotate/gold_multi/multi.py,cover
rename : test/farm/annotate/gold_v24/white.py,cover => tests/farm/annotate/gold_v24/white.py,cover
rename : test/farm/annotate/run.py => tests/farm/annotate/run.py
rename : test/farm/annotate/run_multi.py => tests/farm/annotate/run_multi.py
rename : test/farm/annotate/src/a/__init__.py => tests/farm/annotate/src/a/__init__.py
rename : test/farm/annotate/src/a/a.py => tests/farm/annotate/src/a/a.py
rename : test/farm/annotate/src/b/__init__.py => tests/farm/annotate/src/b/__init__.py
rename : test/farm/annotate/src/b/b.py => tests/farm/annotate/src/b/b.py
rename : test/farm/annotate/src/multi.py => tests/farm/annotate/src/multi.py
rename : test/farm/annotate/src/white.py => tests/farm/annotate/src/white.py
rename : test/farm/html/gold_a/a.html => tests/farm/html/gold_a/a.html
rename : test/farm/html/gold_a/index.html => tests/farm/html/gold_a/index.html
rename : test/farm/html/gold_b_branch/b.html => tests/farm/html/gold_b_branch/b.html
rename : test/farm/html/gold_b_branch/index.html => tests/farm/html/gold_b_branch/index.html
rename : test/farm/html/gold_bom/bom.html => tests/farm/html/gold_bom/bom.html
rename : test/farm/html/gold_bom/index.html => tests/farm/html/gold_bom/index.html
rename : test/farm/html/gold_isolatin1/index.html => tests/farm/html/gold_isolatin1/index.html
rename : test/farm/html/gold_isolatin1/isolatin1.html => tests/farm/html/gold_isolatin1/isolatin1.html
rename : test/farm/html/gold_omit_1/index.html => tests/farm/html/gold_omit_1/index.html
rename : test/farm/html/gold_omit_1/m1.html => tests/farm/html/gold_omit_1/m1.html
rename : test/farm/html/gold_omit_1/m2.html => tests/farm/html/gold_omit_1/m2.html
rename : test/farm/html/gold_omit_1/m3.html => tests/farm/html/gold_omit_1/m3.html
rename : test/farm/html/gold_omit_1/main.html => tests/farm/html/gold_omit_1/main.html
rename : test/farm/html/gold_omit_2/index.html => tests/farm/html/gold_omit_2/index.html
rename : test/farm/html/gold_omit_2/m2.html => tests/farm/html/gold_omit_2/m2.html
rename : test/farm/html/gold_omit_2/m3.html => tests/farm/html/gold_omit_2/m3.html
rename : test/farm/html/gold_omit_2/main.html => tests/farm/html/gold_omit_2/main.html
rename : test/farm/html/gold_omit_3/index.html => tests/farm/html/gold_omit_3/index.html
rename : test/farm/html/gold_omit_3/m3.html => tests/farm/html/gold_omit_3/m3.html
rename : test/farm/html/gold_omit_3/main.html => tests/farm/html/gold_omit_3/main.html
rename : test/farm/html/gold_omit_4/index.html => tests/farm/html/gold_omit_4/index.html
rename : test/farm/html/gold_omit_4/m1.html => tests/farm/html/gold_omit_4/m1.html
rename : test/farm/html/gold_omit_4/m3.html => tests/farm/html/gold_omit_4/m3.html
rename : test/farm/html/gold_omit_4/main.html => tests/farm/html/gold_omit_4/main.html
rename : test/farm/html/gold_omit_5/index.html => tests/farm/html/gold_omit_5/index.html
rename : test/farm/html/gold_omit_5/m1.html => tests/farm/html/gold_omit_5/m1.html
rename : test/farm/html/gold_omit_5/main.html => tests/farm/html/gold_omit_5/main.html
rename : test/farm/html/gold_other/blah_blah_other.html => tests/farm/html/gold_other/blah_blah_other.html
rename : test/farm/html/gold_other/here.html => tests/farm/html/gold_other/here.html
rename : test/farm/html/gold_other/index.html => tests/farm/html/gold_other/index.html
rename : test/farm/html/gold_partial/index.html => tests/farm/html/gold_partial/index.html
rename : test/farm/html/gold_partial/partial.html => tests/farm/html/gold_partial/partial.html
rename : test/farm/html/gold_styled/a.html => tests/farm/html/gold_styled/a.html
rename : test/farm/html/gold_styled/extra.css => tests/farm/html/gold_styled/extra.css
rename : test/farm/html/gold_styled/index.html => tests/farm/html/gold_styled/index.html
rename : test/farm/html/gold_styled/style.css => tests/farm/html/gold_styled/style.css
rename : test/farm/html/gold_unicode/index.html => tests/farm/html/gold_unicode/index.html
rename : test/farm/html/gold_unicode/unicode.html => tests/farm/html/gold_unicode/unicode.html
rename : test/farm/html/gold_x_xml/coverage.xml => tests/farm/html/gold_x_xml/coverage.xml
rename : test/farm/html/gold_y_xml_branch/coverage.xml => tests/farm/html/gold_y_xml_branch/coverage.xml
rename : test/farm/html/othersrc/other.py => tests/farm/html/othersrc/other.py
rename : test/farm/html/run_a.py => tests/farm/html/run_a.py
rename : test/farm/html/run_a_xml_1.py => tests/farm/html/run_a_xml_1.py
rename : test/farm/html/run_a_xml_2.py => tests/farm/html/run_a_xml_2.py
rename : test/farm/html/run_b_branch.py => tests/farm/html/run_b_branch.py
rename : test/farm/html/run_bom.py => tests/farm/html/run_bom.py
rename : test/farm/html/run_isolatin1.py => tests/farm/html/run_isolatin1.py
rename : test/farm/html/run_omit_1.py => tests/farm/html/run_omit_1.py
rename : test/farm/html/run_omit_2.py => tests/farm/html/run_omit_2.py
rename : test/farm/html/run_omit_3.py => tests/farm/html/run_omit_3.py
rename : test/farm/html/run_omit_4.py => tests/farm/html/run_omit_4.py
rename : test/farm/html/run_omit_5.py => tests/farm/html/run_omit_5.py
rename : test/farm/html/run_other.py => tests/farm/html/run_other.py
rename : test/farm/html/run_partial.py => tests/farm/html/run_partial.py
rename : test/farm/html/run_styled.py => tests/farm/html/run_styled.py
rename : test/farm/html/run_tabbed.py => tests/farm/html/run_tabbed.py
rename : test/farm/html/run_unicode.py => tests/farm/html/run_unicode.py
rename : test/farm/html/run_y_xml_branch.py => tests/farm/html/run_y_xml_branch.py
rename : test/farm/html/src/a.py => tests/farm/html/src/a.py
rename : test/farm/html/src/b.py => tests/farm/html/src/b.py
rename : test/farm/html/src/bom.py => tests/farm/html/src/bom.py
rename : test/farm/html/src/coverage.xml => tests/farm/html/src/coverage.xml
rename : test/farm/html/src/extra.css => tests/farm/html/src/extra.css
rename : test/farm/html/src/here.py => tests/farm/html/src/here.py
rename : test/farm/html/src/isolatin1.py => tests/farm/html/src/isolatin1.py
rename : test/farm/html/src/m1.py => tests/farm/html/src/m1.py
rename : test/farm/html/src/m2.py => tests/farm/html/src/m2.py
rename : test/farm/html/src/m3.py => tests/farm/html/src/m3.py
rename : test/farm/html/src/main.py => tests/farm/html/src/main.py
rename : test/farm/html/src/omit4.ini => tests/farm/html/src/omit4.ini
rename : test/farm/html/src/omit5.ini => tests/farm/html/src/omit5.ini
rename : test/farm/html/src/partial.py => tests/farm/html/src/partial.py
rename : test/farm/html/src/run_a_xml_2.ini => tests/farm/html/src/run_a_xml_2.ini
rename : test/farm/html/src/tabbed.py => tests/farm/html/src/tabbed.py
rename : test/farm/html/src/unicode.py => tests/farm/html/src/unicode.py
rename : test/farm/html/src/y.py => tests/farm/html/src/y.py
rename : test/farm/run/run_chdir.py => tests/farm/run/run_chdir.py
rename : test/farm/run/run_timid.py => tests/farm/run/run_timid.py
rename : test/farm/run/run_xxx.py => tests/farm/run/run_xxx.py
rename : test/farm/run/src/chdir.py => tests/farm/run/src/chdir.py
rename : test/farm/run/src/showtrace.py => tests/farm/run/src/showtrace.py
rename : test/farm/run/src/subdir/placeholder => tests/farm/run/src/subdir/placeholder
rename : test/farm/run/src/xxx => tests/farm/run/src/xxx
rename : test/js/index.html => tests/js/index.html
rename : test/js/tests.js => tests/js/tests.js
rename : test/modules/aa/__init__.py => tests/modules/aa/__init__.py
rename : test/modules/aa/afile.odd.py => tests/modules/aa/afile.odd.py
rename : test/modules/aa/afile.py => tests/modules/aa/afile.py
rename : test/modules/aa/bb.odd/bfile.py => tests/modules/aa/bb.odd/bfile.py
rename : test/modules/aa/bb/__init__.py => tests/modules/aa/bb/__init__.py
rename : test/modules/aa/bb/bfile.odd.py => tests/modules/aa/bb/bfile.odd.py
rename : test/modules/aa/bb/bfile.py => tests/modules/aa/bb/bfile.py
rename : test/modules/aa/bb/cc/__init__.py => tests/modules/aa/bb/cc/__init__.py
rename : test/modules/aa/bb/cc/cfile.py => tests/modules/aa/bb/cc/cfile.py
rename : test/modules/aa/zfile.py => tests/modules/aa/zfile.py
rename : test/modules/covmod1.py => tests/modules/covmod1.py
rename : test/modules/pkg1/__init__.py => tests/modules/pkg1/__init__.py
rename : test/modules/pkg1/__main__.py => tests/modules/pkg1/__main__.py
rename : test/modules/pkg1/p1a.py => tests/modules/pkg1/p1a.py
rename : test/modules/pkg1/p1b.py => tests/modules/pkg1/p1b.py
rename : test/modules/pkg1/p1c.py => tests/modules/pkg1/p1c.py
rename : test/modules/pkg1/runmod2.py => tests/modules/pkg1/runmod2.py
rename : test/modules/pkg1/sub/__init__.py => tests/modules/pkg1/sub/__init__.py
rename : test/modules/pkg1/sub/__main__.py => tests/modules/pkg1/sub/__main__.py
rename : test/modules/pkg1/sub/ps1a.py => tests/modules/pkg1/sub/ps1a.py
rename : test/modules/pkg1/sub/runmod3.py => tests/modules/pkg1/sub/runmod3.py
rename : test/modules/pkg2/__init__.py => tests/modules/pkg2/__init__.py
rename : test/modules/pkg2/p2a.py => tests/modules/pkg2/p2a.py
rename : test/modules/pkg2/p2b.py => tests/modules/pkg2/p2b.py
rename : test/modules/runmod1.py => tests/modules/runmod1.py
rename : test/modules/usepkgs.py => tests/modules/usepkgs.py
rename : test/moremodules/othermods/__init__.py => tests/moremodules/othermods/__init__.py
rename : test/moremodules/othermods/othera.py => tests/moremodules/othermods/othera.py
rename : test/moremodules/othermods/otherb.py => tests/moremodules/othermods/otherb.py
rename : test/moremodules/othermods/sub/__init__.py => tests/moremodules/othermods/sub/__init__.py
rename : test/moremodules/othermods/sub/osa.py => tests/moremodules/othermods/sub/osa.py
rename : test/moremodules/othermods/sub/osb.py => tests/moremodules/othermods/sub/osb.py
rename : test/osinfo.py => tests/osinfo.py
rename : test/qunit/jquery.tmpl.min.js => tests/qunit/jquery.tmpl.min.js
rename : test/qunit/qunit.css => tests/qunit/qunit.css
rename : test/qunit/qunit.js => tests/qunit/qunit.js
rename : test/stress_phystoken.tok => tests/stress_phystoken.tok
rename : test/stress_phystoken_dos.tok => tests/stress_phystoken_dos.tok
rename : test/test_api.py => tests/test_api.py
rename : test/test_arcs.py => tests/test_arcs.py
rename : test/test_cmdline.py => tests/test_cmdline.py
rename : test/test_codeunit.py => tests/test_codeunit.py
rename : test/test_config.py => tests/test_config.py
rename : test/test_coverage.py => tests/test_coverage.py
rename : test/test_data.py => tests/test_data.py
rename : test/test_execfile.py => tests/test_execfile.py
rename : test/test_farm.py => tests/test_farm.py
rename : test/test_files.py => tests/test_files.py
rename : test/test_html.py => tests/test_html.py
rename : test/test_misc.py => tests/test_misc.py
rename : test/test_oddball.py => tests/test_oddball.py
rename : test/test_parser.py => tests/test_parser.py
rename : test/test_phystokens.py => tests/test_phystokens.py
rename : test/test_process.py => tests/test_process.py
rename : test/test_results.py => tests/test_results.py
rename : test/test_summary.py => tests/test_summary.py
rename : test/test_templite.py => tests/test_templite.py
rename : test/test_testing.py => tests/test_testing.py
rename : test/test_xml.py => tests/test_xml.py
rename : test/try_execfile.py => tests/try_execfile.py
Diffstat (limited to 'test/test_html.py')
-rw-r--r-- | test/test_html.py | 297 |
1 files changed, 0 insertions, 297 deletions
diff --git a/test/test_html.py b/test/test_html.py deleted file mode 100644 index 66d1bd7d..00000000 --- a/test/test_html.py +++ /dev/null @@ -1,297 +0,0 @@ -# -*- coding: utf-8 -*- -"""Tests that HTML generation is awesome.""" - -import os.path, re, sys -import coverage -from coverage.misc import NotPython, NoSource - -from test.coveragetest import CoverageTest - -class HtmlTestHelpers(CoverageTest): - """Methods that help with HTML tests.""" - - def create_initial_files(self): - """Create the source files we need to run these tests.""" - self.make_file("main_file.py", """\ - import helper1, helper2 - helper1.func1(12) - helper2.func2(12) - """) - self.make_file("helper1.py", """\ - def func1(x): - if x % 2: - print("odd") - """) - self.make_file("helper2.py", """\ - def func2(x): - print("x is %d" % x) - """) - - def run_coverage(self, covargs=None, htmlargs=None): - """Run coverage on main_file.py, and create an HTML report.""" - self.clean_local_file_imports() - cov = coverage.coverage(**(covargs or {})) - self.start_import_stop(cov, "main_file") - cov.html_report(**(htmlargs or {})) - - def remove_html_files(self): - """Remove the HTML files created as part of the HTML report.""" - os.remove("htmlcov/index.html") - os.remove("htmlcov/main_file.html") - os.remove("htmlcov/helper1.html") - os.remove("htmlcov/helper2.html") - - -class HtmlDeltaTest(HtmlTestHelpers, CoverageTest): - """Tests of the HTML delta speed-ups.""" - - def setUp(self): - super(HtmlDeltaTest, self).setUp() - - # At least one of our tests monkey-patches the version of coverage, - # so grab it here to restore it later. - self.real_coverage_version = coverage.__version__ - - self.maxDiff = None - - def tearDown(self): - coverage.__version__ = self.real_coverage_version - super(HtmlDeltaTest, self).tearDown() - - def test_html_created(self): - # Test basic HTML generation: files should be created. - self.create_initial_files() - self.run_coverage() - - self.assert_exists("htmlcov/index.html") - self.assert_exists("htmlcov/main_file.html") - self.assert_exists("htmlcov/helper1.html") - self.assert_exists("htmlcov/helper2.html") - self.assert_exists("htmlcov/style.css") - self.assert_exists("htmlcov/coverage_html.js") - - def test_html_delta_from_source_change(self): - # HTML generation can create only the files that have changed. - # In this case, helper1 changes because its source is different. - self.create_initial_files() - self.run_coverage() - index1 = open("htmlcov/index.html").read() - self.remove_html_files() - - # Now change a file and do it again - self.make_file("helper1.py", """\ - def func1(x): # A nice function - if x % 2: - print("odd") - """) - - self.run_coverage() - - # Only the changed files should have been created. - self.assert_exists("htmlcov/index.html") - self.assert_exists("htmlcov/helper1.html") - self.assert_doesnt_exist("htmlcov/main_file.html") - self.assert_doesnt_exist("htmlcov/helper2.html") - index2 = open("htmlcov/index.html").read() - self.assertMultiLineEqual(index1, index2) - - def test_html_delta_from_coverage_change(self): - # HTML generation can create only the files that have changed. - # In this case, helper1 changes because its coverage is different. - self.create_initial_files() - self.run_coverage() - self.remove_html_files() - - # Now change a file and do it again - self.make_file("main_file.py", """\ - import helper1, helper2 - helper1.func1(23) - helper2.func2(23) - """) - - self.run_coverage() - - # Only the changed files should have been created. - self.assert_exists("htmlcov/index.html") - self.assert_exists("htmlcov/helper1.html") - self.assert_exists("htmlcov/main_file.html") - self.assert_doesnt_exist("htmlcov/helper2.html") - - def test_html_delta_from_settings_change(self): - # HTML generation can create only the files that have changed. - # In this case, everything changes because the coverage settings have - # changed. - self.create_initial_files() - self.run_coverage(covargs=dict(omit=[])) - index1 = open("htmlcov/index.html").read() - self.remove_html_files() - - self.run_coverage(covargs=dict(omit=['xyzzy*'])) - - # All the files have been reported again. - self.assert_exists("htmlcov/index.html") - self.assert_exists("htmlcov/helper1.html") - self.assert_exists("htmlcov/main_file.html") - self.assert_exists("htmlcov/helper2.html") - index2 = open("htmlcov/index.html").read() - self.assertMultiLineEqual(index1, index2) - - def test_html_delta_from_coverage_version_change(self): - # HTML generation can create only the files that have changed. - # In this case, everything changes because the coverage version has - # changed. - self.create_initial_files() - self.run_coverage() - index1 = open("htmlcov/index.html").read() - self.remove_html_files() - - # "Upgrade" coverage.py! - coverage.__version__ = "XYZZY" - - self.run_coverage() - - # All the files have been reported again. - self.assert_exists("htmlcov/index.html") - self.assert_exists("htmlcov/helper1.html") - self.assert_exists("htmlcov/main_file.html") - self.assert_exists("htmlcov/helper2.html") - index2 = open("htmlcov/index.html").read() - fixed_index2 = index2.replace("XYZZY", self.real_coverage_version) - self.assertMultiLineEqual(index1, fixed_index2) - - -class HtmlTitleTests(HtmlTestHelpers, CoverageTest): - """Tests of the HTML title support.""" - - def test_default_title(self): - self.create_initial_files() - self.run_coverage() - index = open("htmlcov/index.html").read() - self.assertIn("<title>Coverage report</title>", index) - self.assertIn("<h1>Coverage report:", index) - - def test_title_set_in_config_file(self): - self.create_initial_files() - self.make_file(".coveragerc", "[html]\ntitle = Metrics & stuff!\n") - self.run_coverage() - index = open("htmlcov/index.html").read() - self.assertIn("<title>Metrics & stuff!</title>", index) - self.assertIn("<h1>Metrics & stuff!:", index) - - if sys.version_info[:2] != (3,1): - def test_non_ascii_title_set_in_config_file(self): - self.create_initial_files() - self.make_file(".coveragerc", - "[html]\ntitle = «ταБЬℓσ» numbers" - ) - self.run_coverage() - index = open("htmlcov/index.html").read() - self.assertIn( - "<title>«ταБЬℓσ»" - " numbers", index - ) - self.assertIn( - "<h1>«ταБЬℓσ»" - " numbers", index - ) - - def test_title_set_in_args(self): - self.create_initial_files() - self.make_file(".coveragerc", "[html]\ntitle = Good title\n") - self.run_coverage(htmlargs=dict(title="«ταБЬℓσ» & stüff!")) - index = open("htmlcov/index.html").read() - self.assertIn( - "<title>«ταБЬℓσ»" - " & stüff!</title>", index - ) - self.assertIn( - "<h1>«ταБЬℓσ»" - " & stüff!:", index - ) - - -class HtmlWithUnparsableFilesTest(CoverageTest): - """Test the behavior when measuring unparsable files.""" - - def test_dotpy_not_python(self): - self.make_file("innocuous.py", "a = 1") - cov = coverage.coverage() - self.start_import_stop(cov, "innocuous") - self.make_file("innocuous.py", "<h1>This isn't python!</h1>") - self.assertRaisesRegexp( - NotPython, - "Couldn't parse '.*innocuous.py' as Python source: '.*' at line 1", - cov.html_report - ) - - def test_dotpy_not_python_ignored(self): - self.make_file("innocuous.py", "a = 2") - cov = coverage.coverage() - self.start_import_stop(cov, "innocuous") - self.make_file("innocuous.py", "<h1>This isn't python!</h1>") - cov.html_report(ignore_errors=True) - self.assert_exists("htmlcov/index.html") - # this would be better as a glob, if the html layout changes: - self.assert_doesnt_exist("htmlcov/innocuous.html") - - def test_dothtml_not_python(self): - # We run a .html file, and when reporting, we can't parse it as - # Python. Since it wasn't .py, no error is reported. - - # Run an "html" file - self.make_file("innocuous.html", "a = 3") - self.run_command("coverage run innocuous.html") - # Before reporting, change it to be an HTML file. - self.make_file("innocuous.html", "<h1>This isn't python at all!</h1>") - output = self.run_command("coverage html") - self.assertEqual(output.strip(), "No data to report.") - - def test_execed_liar_ignored(self): - # Jinja2 sets __file__ to be a non-Python file, and then execs code. - # If that file contains non-Python code, a TokenError shouldn't - # have been raised when writing the HTML report. - if sys.version_info < (3, 0): - source = "exec compile('','','exec') in {'__file__': 'liar.html'}" - else: - source = "exec(compile('','','exec'), {'__file__': 'liar.html'})" - self.make_file("liar.py", source) - self.make_file("liar.html", "{# Whoops, not python code #}") - cov = coverage.coverage() - self.start_import_stop(cov, "liar") - cov.html_report() - self.assert_exists("htmlcov/index.html") - - def test_execed_liar_ignored_indentation_error(self): - # Jinja2 sets __file__ to be a non-Python file, and then execs code. - # If that file contains untokenizable code, we shouldn't get an - # exception. - if sys.version_info < (3, 0): - source = "exec compile('','','exec') in {'__file__': 'liar.html'}" - else: - source = "exec(compile('','','exec'), {'__file__': 'liar.html'})" - self.make_file("liar.py", source) - # Tokenize will raise an IndentationError if it can't dedent. - self.make_file("liar.html", "0\n 2\n 1\n") - cov = coverage.coverage() - self.start_import_stop(cov, "liar") - cov.html_report() - self.assert_exists("htmlcov/index.html") - - -class HtmlTest(CoverageTest): - """Moar HTML tests.""" - - def test_missing_source_file_incorrect_message(self): - # https://bitbucket.org/ned/coveragepy/issue/60 - self.make_file("thefile.py", "import sub.another\n") - self.make_file("sub/__init__.py", "") - self.make_file("sub/another.py", "print('another')\n") - cov = coverage.coverage() - self.start_import_stop(cov, 'thefile') - os.remove("sub/another.py") - - missing_file = os.path.join(self.temp_dir, "sub", "another.py") - self.assertRaisesRegexp(NoSource, - "(?i)No source for code: '%s'" % re.escape(missing_file), - cov.html_report - ) |