[LNT] r349579 - Getting server UI tests working in flake8
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 18 15:39:27 PST 2018
Author: cmatthews
Date: Tue Dec 18 15:39:26 2018
New Revision: 349579
URL: http://llvm.org/viewvc/llvm-project?rev=349579&view=rev
Log:
Getting server UI tests working in flake8
These were all valid style or correctness issues.
Modified:
lnt/trunk/setup.cfg
lnt/trunk/tests/server/ui/V4Pages.py
lnt/trunk/tests/server/ui/statsTester.py
lnt/trunk/tests/server/ui/test_api_modify.py
lnt/trunk/tests/server/ui/test_matrix_page.py
lnt/trunk/tox.ini
Modified: lnt/trunk/setup.cfg
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/setup.cfg?rev=349579&r1=349578&r2=349579&view=diff
==============================================================================
--- lnt/trunk/setup.cfg (original)
+++ lnt/trunk/setup.cfg Tue Dec 18 15:39:26 2018
@@ -1,4 +1,4 @@
[flake8]
-ignore = E712,E402,E711, E266
+ignore = E712,E402,E711, E266, W605
max-line-length = 120
count = True
\ No newline at end of file
Modified: lnt/trunk/tests/server/ui/V4Pages.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/V4Pages.py?rev=349579&r1=349578&r2=349579&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/V4Pages.py (original)
+++ lnt/trunk/tests/server/ui/V4Pages.py Tue Dec 18 15:39:26 2018
@@ -22,13 +22,13 @@ from flask import session
import lnt.server.db.migrate
import lnt.server.ui.app
import json
-import HTMLParser
# We can validate html if pytidylib is available and tidy-html5 is installed.
# The user can indicate this by passing --use-tidylib to the script (triggered
# by `lit -Dtidylib=1`)
if '--use-tidylib' in sys.argv:
import tidylib
+
def validate_html(text):
document, errors = tidylib.tidy_document(text)
had_error = False
@@ -99,8 +99,8 @@ def check_redirect(client, url, expected
def dump_html(html_string):
- for linenr, line in enumerate(html_string.split('\n')):
- print "%4d:%s" % (linenr+1, line)
+ for linenr, line in enumerate(html_string.split('\n')):
+ print "%4d:%s" % (linenr + 1, line)
def get_xml_tree(html_string):
@@ -109,15 +109,14 @@ def get_xml_tree(html_string):
parser.parser.UseForeignDTD(True)
parser.entity.update((x, unichr(i)) for x, i in name2codepoint.iteritems())
tree = ET.fromstring(html_string, parser=parser)
- except:
- dump_html(html_string)
- raise
+ except: # noqa FIXME: figure out what we expect this to throw.
+ dump_html(html_string)
+ raise
return tree
def find_table_by_thead_content(tree, table_head_contents):
all_tables = tree.findall(".//thead/..")
- found_header = False
for table in all_tables:
for child in table.findall('./thead/tr/th'):
if child.text == table_head_contents:
@@ -133,8 +132,7 @@ def find_table_with_heading(tree, table_
if found_header:
if child.tag == "table":
return child
- elif (child.tag.startswith('h') and
- child.text == table_heading):
+ elif child.tag.startswith('h') and child.text == table_heading:
found_header = True
return None
@@ -178,14 +176,14 @@ def get_results_table(client, url, field
def get_table_body_content(table):
return [[convert_html_to_text(cell).strip()
for cell in row.findall("./td")]
- for row in table.findall("./tbody/tr")]
+ for row in table.findall("./tbody/tr")]
def get_table_links(table):
return [[link.get("href")
for cell in row.findall("./td")
for link in cell.findall("a")]
- for row in table.findall("./tbody/tr")]
+ for row in table.findall("./tbody/tr")]
def check_row_is_in_table(table, expected_row_content):
@@ -303,7 +301,7 @@ def main():
# Get a machine overview page.
check_html(client, '/v4/nts/machine/1')
# Check invalid machine gives error.
- check_code(client, '/v4/nts/machine/9999', expected_code=HTTP_NOT_FOUND)
+ check_code(client, '/v4/nts/machine/9999', expected_code=HTTP_NOT_FOUND)
# Get a machine overview page in JSON format.
check_json(client, '/v4/nts/machine/1?json=true')
Modified: lnt/trunk/tests/server/ui/statsTester.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/statsTester.py?rev=349579&r1=349578&r2=349579&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/statsTester.py (original)
+++ lnt/trunk/tests/server/ui/statsTester.py Tue Dec 18 15:39:26 2018
@@ -52,6 +52,7 @@ class TestLNTStatsTester(unittest.TestCa
(value, index) for (index, value) in enumerate(test_list3))
self.assertEqual((1.0, INDEX), (agg_value, agg_index))
+
if __name__ == '__main__':
try:
unittest.main()
Modified: lnt/trunk/tests/server/ui/test_api_modify.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/test_api_modify.py?rev=349579&r1=349578&r2=349579&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/test_api_modify.py (original)
+++ lnt/trunk/tests/server/ui/test_api_modify.py Tue Dec 18 15:39:26 2018
@@ -149,7 +149,7 @@ class JSONAPIDeleteTester(unittest.TestC
headers={'AuthToken': 'test_token'})
self.assertEqual(resp.status_code, 200)
self.assertEqual(resp.get_data(),
-'''Deleting runs 3 5 6 7 8 9 (6/6)
+ '''Deleting runs 3 5 6 7 8 9 (6/6)
Deleted machine machine2:2
''')
Modified: lnt/trunk/tests/server/ui/test_matrix_page.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/test_matrix_page.py?rev=349579&r1=349578&r2=349579&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/test_matrix_page.py (original)
+++ lnt/trunk/tests/server/ui/test_matrix_page.py Tue Dec 18 15:39:26 2018
@@ -14,10 +14,11 @@ import sys
import lnt.server.db.migrate
import lnt.server.ui.app
-from V4Pages import check_json, check_code, check_html
-from V4Pages import HTTP_REDIRECT, HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND
+from V4Pages import check_code, check_html
+from V4Pages import HTTP_REDIRECT, HTTP_BAD_REQUEST, HTTP_NOT_FOUND
logging.basicConfig(level=logging.DEBUG)
+
class MatrixViewTester(unittest.TestCase):
"""Test the Matrix view."""
@@ -40,7 +41,7 @@ class MatrixViewTester(unittest.TestCase
reply = check_code(client, '/v4/nts/matrix?plot.0=1.1.1',
expected_code=HTTP_NOT_FOUND)
self.assertIn("No data found.", reply.data)
-
+
reply = check_code(client, '/v4/nts/matrix?plot.0=a.2.0',
expected_code=HTTP_BAD_REQUEST)
self.assertIn("malformed", reply.data)
Modified: lnt/trunk/tox.ini
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tox.ini?rev=349579&r1=349578&r2=349579&view=diff
==============================================================================
--- lnt/trunk/tox.ini (original)
+++ lnt/trunk/tox.ini Tue Dec 18 15:39:26 2018
@@ -4,6 +4,7 @@
whitelist_files = ./setup.py
./deployment/
./lnt/formats/
+ ./tests/server/ui/
[tox]
envlist = py27
More information about the llvm-commits
mailing list