From 78e2c8c6e014b205e5f2cf7764ca9cf3597b318a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 20 Apr 2012 17:37:11 -0400 Subject: The [html]extra_css configuration value is a file path to a CSS file that gets copied into the HTML report. --- test/farm/html/gold_styled/a.html | 95 ++++++++++++ test/farm/html/gold_styled/extra.css | 1 + test/farm/html/gold_styled/index.html | 89 +++++++++++ test/farm/html/gold_styled/style.css | 275 ++++++++++++++++++++++++++++++++++ test/farm/html/run_styled.py | 28 ++++ test/farm/html/src/extra.css | 1 + test/test_config.py | 3 +- 7 files changed, 491 insertions(+), 1 deletion(-) create mode 100644 test/farm/html/gold_styled/a.html create mode 100644 test/farm/html/gold_styled/extra.css create mode 100644 test/farm/html/gold_styled/index.html create mode 100644 test/farm/html/gold_styled/style.css create mode 100644 test/farm/html/run_styled.py create mode 100644 test/farm/html/src/extra.css (limited to 'test') diff --git a/test/farm/html/gold_styled/a.html b/test/farm/html/gold_styled/a.html new file mode 100644 index 00000000..c794525e --- /dev/null +++ b/test/farm/html/gold_styled/a.html @@ -0,0 +1,95 @@ + + + + + + + + Coverage for a: 67% + + + + + + + + + + + +
+ +

Hot-keys on this page

+
+

+ r + m + x + p   toggle line displays +

+

+ j + k   next/prev highlighted chunk +

+

+ 0   (zero) top of page +

+

+ 1   (one) first highlighted chunk +

+
+
+ +
+ + + + + +
+

1

+

2

+

3

+

4

+

5

+

6

+

7

+ +
+

# 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/farm/html/gold_styled/extra.css b/test/farm/html/gold_styled/extra.css new file mode 100644 index 00000000..46c41fcd --- /dev/null +++ b/test/farm/html/gold_styled/extra.css @@ -0,0 +1 @@ +/* Doesn't matter what goes in here, it gets copied. */ diff --git a/test/farm/html/gold_styled/index.html b/test/farm/html/gold_styled/index.html new file mode 100644 index 00000000..a821e9df --- /dev/null +++ b/test/farm/html/gold_styled/index.html @@ -0,0 +1,89 @@ + + + + + Coverage report + + + + + + + + + + + +
+ +

Hot-keys on this page

+
+

+ n + s + m + x + + c   change column sorting +

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Modulestatementsmissingexcludedcoverage
Total31067%
a31067%
+
+ + + + + diff --git a/test/farm/html/gold_styled/style.css b/test/farm/html/gold_styled/style.css new file mode 100644 index 00000000..c40357b8 --- /dev/null +++ b/test/farm/html/gold_styled/style.css @@ -0,0 +1,275 @@ +/* CSS styles for Coverage. */ +/* Page-wide styles */ +html, body, h1, h2, h3, p, td, th { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-weight: inherit; + font-style: inherit; + font-size: 100%; + font-family: inherit; + vertical-align: baseline; + } + +/* Set baseline grid to 16 pt. */ +body { + font-family: georgia, serif; + font-size: 1em; + } + +html>body { + font-size: 16px; + } + +/* Set base font size to 12/16 */ +p { + font-size: .75em; /* 12/16 */ + line-height: 1.3333em; /* 16/12 */ + } + +table { + border-collapse: collapse; + } + +a.nav { + text-decoration: none; + color: inherit; + } +a.nav:hover { + text-decoration: underline; + color: inherit; + } + +/* Page structure */ +#header { + background: #f8f8f8; + width: 100%; + border-bottom: 1px solid #eee; + } + +#source { + padding: 1em; + font-family: "courier new", monospace; + } + +#indexfile #footer { + margin: 1em 3em; + } + +#pyfile #footer { + margin: 1em 1em; + } + +#footer .content { + padding: 0; + font-size: 85%; + font-family: verdana, sans-serif; + color: #666666; + font-style: italic; + } + +#index { + margin: 1em 0 0 3em; + } + +/* Header styles */ +#header .content { + padding: 1em 3em; + } + +h1 { + font-size: 1.25em; +} + +h2.stats { + margin-top: .5em; + font-size: 1em; +} +.stats span { + border: 1px solid; + padding: .1em .25em; + margin: 0 .1em; + cursor: pointer; + border-color: #999 #ccc #ccc #999; +} +.stats span.hide_run, .stats span.hide_exc, +.stats span.hide_mis, .stats span.hide_par, +.stats span.par.hide_run.hide_par { + border-color: #ccc #999 #999 #ccc; +} +.stats span.par.hide_run { + border-color: #999 #ccc #ccc #999; +} + +/* Help panel */ +#keyboard_icon { + float: right; + cursor: pointer; +} + +.help_panel { + position: absolute; + background: #ffc; + padding: .5em; + border: 1px solid #883; + display: none; +} + +#indexfile .help_panel { + width: 20em; height: 4em; +} + +#pyfile .help_panel { + width: 16em; height: 8em; +} + +.help_panel .legend { + font-style: italic; + margin-bottom: 1em; +} + +#panel_icon { + float: right; + cursor: pointer; +} + +.keyhelp { + margin: .75em; +} + +.keyhelp .key { + border: 1px solid black; + border-color: #888 #333 #333 #888; + padding: .1em .35em; + font-family: monospace; + font-weight: bold; + background: #eee; +} + +/* Source file styles */ +.linenos p { + text-align: right; + margin: 0; + padding: 0 .5em; + color: #999999; + font-family: verdana, sans-serif; + font-size: .625em; /* 10/16 */ + line-height: 1.6em; /* 16/10 */ + } +.linenos p.highlight { + background: #ffdd00; + } +.linenos p a { + text-decoration: none; + color: #999999; + } +.linenos p a:hover { + text-decoration: underline; + color: #999999; + } + +td.text { + width: 100%; + } +.text p { + margin: 0; + padding: 0 0 0 .5em; + border-left: 2px solid #ffffff; + white-space: nowrap; + } + +.text p.mis { + background: #ffdddd; + border-left: 2px solid #ff0000; + } +.text p.run, .text p.run.hide_par { + background: #ddffdd; + border-left: 2px solid #00ff00; + } +.text p.exc { + background: #eeeeee; + border-left: 2px solid #808080; + } +.text p.par, .text p.par.hide_run { + background: #ffffaa; + border-left: 2px solid #eeee99; + } +.text p.hide_run, .text p.hide_exc, .text p.hide_mis, .text p.hide_par, +.text p.hide_run.hide_par { + background: inherit; + } + +.text span.annotate { + font-family: georgia; + font-style: italic; + color: #666; + float: right; + padding-right: .5em; + } +.text p.hide_par span.annotate { + display: none; + } + +/* Syntax coloring */ +.text .com { + color: green; + font-style: italic; + line-height: 1px; + } +.text .key { + font-weight: bold; + line-height: 1px; + } +.text .str { + color: #000080; + } + +/* index styles */ +#index td, #index th { + text-align: right; + width: 5em; + padding: .25em .5em; + border-bottom: 1px solid #eee; + } +#index th { + font-style: italic; + color: #333; + border-bottom: 1px solid #ccc; + cursor: pointer; + } +#index th:hover { + background: #eee; + border-bottom: 1px solid #999; + } +#index td.left, #index th.left { + padding-left: 0; + } +#index td.right, #index th.right { + padding-right: 0; + } +#index th.headerSortDown, #index th.headerSortUp { + border-bottom: 1px solid #000; + } +#index td.name, #index th.name { + text-align: left; + width: auto; + } +#index td.name a { + text-decoration: none; + color: #000; + } +#index td.name a:hover { + text-decoration: underline; + color: #000; + } +#index tr.total { + } +#index tr.total td { + font-weight: bold; + border-top: 1px solid #ccc; + border-bottom: none; + } +#index tr.file:hover { + background: #eeeeee; + } diff --git a/test/farm/html/run_styled.py b/test/farm/html/run_styled.py new file mode 100644 index 00000000..3a212957 --- /dev/null +++ b/test/farm/html/run_styled.py @@ -0,0 +1,28 @@ +def html_it(): + """Run coverage and make an HTML report for a.""" + import coverage + cov = coverage.coverage() + cov.start() + import a + cov.stop() + cov.html_report(a, directory="../html_styled", extra_css="extra.css") + +runfunc(html_it, rundir="src") + +# HTML files will change often. Check that the sizes are reasonable, +# and check that certain key strings are in the output. +compare("gold_styled", "html_styled", size_within=10, file_pattern="*.html") +compare("gold_styled", "html_styled", size_within=10, file_pattern="*.css") +contains("html_styled/a.html", + "", + "if 1 < 2", + "    a = 3", + "67%" + ) +contains("html_styled/index.html", + "", + "a", + "67%" + ) + +clean("html_styled") diff --git a/test/farm/html/src/extra.css b/test/farm/html/src/extra.css new file mode 100644 index 00000000..46c41fcd --- /dev/null +++ b/test/farm/html/src/extra.css @@ -0,0 +1 @@ +/* Doesn't matter what goes in here, it gets copied. */ diff --git a/test/test_config.py b/test/test_config.py index 236216f6..bf42bf76 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -138,7 +138,7 @@ class ConfigFileTest(CoverageTest): [html] directory = c:\\tricky\\dir.somewhere - + extra_css=something/extra.css [xml] output=mycov.xml @@ -176,6 +176,7 @@ class ConfigFileTest(CoverageTest): ) self.assertTrue(cov.config.show_missing) self.assertEqual(cov.config.html_dir, r"c:\tricky\dir.somewhere") + self.assertEqual(cov.config.extra_css, "something/extra.css") self.assertEqual(cov.config.xml_output, "mycov.xml") -- cgit v1.2.1