diff --git a/src/tests/regression.py b/src/tests/regression.py index 601459a..3d8eae3 100644 --- a/src/tests/regression.py +++ b/src/tests/regression.py @@ -33,6 +33,69 @@ TEST_DATA_PATH = os.path.join(TESTDIR, 'test_data') TEST_OUTPUT_PATH = os.path.join(TESTDIR, 'test_output') TEST_SUMMARY_PATH = os.path.join(TEST_OUTPUT_PATH, 'index.html') +SUMMARY_CSS = ''' +table, th, td { + border: 1px solid black; + border-collapse: collapse; + font-family: Georgia, 'Times New Roman', serif; +} +table { + margin: auto; +} +.skipped { + color: gray; +} +td, th { + font-size: 1.2em; + border: 1px solid black; + padding: 3px 7px 2px 7px; +} +th { + font-size: 16px; + text-align: left; + padding-top: 5px; + padding-bottom: 4px; +} +''' + +READABILITY_CSS = ''' +#article { + margin: 0 auto; + max-width: 705px; + min-width: 225px; + font-family: Georgia, 'Times New Roman', serif; + font-size: 19px; + line-height: 29px; +} + +#article p { + font-size: 19px; + line-height: 29px; + margin: 19px 0px 19px 0px; +} + +ins { + background-color: #C6F7C3; + text-decoration: none; +} + +ins img { + border-width: 3px; + border-style: dotted; + border-color: #51B548; +} + +del { + background-color: #F7C3C3; + text-decoration: none; +} + +del img { + border-width: 3px; + border-style: dotted; + border-color: #D12626; +} +''' class ReadabilityTest: @@ -122,32 +185,6 @@ def execute_test(test_data): return ReadabilityTestResult(test_data, summary.html, diff) -SUMMARY_CSS = ''' -table, th, td { - border: 1px solid black; - border-collapse: collapse; - font-family: Georgia, 'Times New Roman', serif; -} -table { - margin: auto; -} -.skipped { - color: gray; -} -td, th { - font-size: 1.2em; - border: 1px solid black; - padding: 3px 7px 2px 7px; -} -th { - font-size: 16px; - text-align: left; - padding-top: 5px; - padding-bottom: 4px; -} -''' - - def element_string_lengths(elems): return [len(e.xpath('string()')) for e in elems] @@ -234,47 +271,8 @@ def write_summary(path, tests_w_results): f.write(lxml.html.tostring(doc)) -CSS = ''' -#article { - margin: 0 auto; - max-width: 705px; - min-width: 225px; - font-family: Georgia, 'Times New Roman', serif; - font-size: 19px; - line-height: 29px; -} - -#article p { - font-size: 19px; - line-height: 29px; - margin: 19px 0px 19px 0px; -} - -ins { - background-color: #C6F7C3; - text-decoration: none; -} - -ins img { - border-width: 3px; - border-style: dotted; - border-color: #51B548; -} - -del { - background-color: #F7C3C3; - text-decoration: none; -} - -del img { - border-width: 3px; - border-style: dotted; - border-color: #D12626; -} -''' - def add_css(doc): - style = B.STYLE(CSS, type = 'text/css') + style = B.STYLE(READABILITY_CSS, type = 'text/css') head = B.HEAD(style, content = 'text/html; charset=utf-8') doc.insert(0, head)