Added more tool tests.
This commit is contained in:
parent
803ee80427
commit
fb93897ac7
11 changed files with 282 additions and 31 deletions
|
|
@ -43,11 +43,13 @@ def run_tool(tool, input_filename):
|
|||
|
||||
class ToolsTestCase(unittest.TestCase):
|
||||
|
||||
def _test_tool(self, tool, input_filename, expected_status):
|
||||
status, result = run_tool(tool, input_filename)
|
||||
golden_path = result_path(tool, input_filename)
|
||||
golden.assertGolden(widget_to_string(result), golden_path)
|
||||
self.assertEqual(status, expected_status)
|
||||
def _sub_tests(self, sub_tests):
|
||||
for tool, input_filename, expected_status in sub_tests:
|
||||
with self.subTest(input_filename=input_filename):
|
||||
status, result = run_tool(tool, input_filename)
|
||||
golden_path = result_path(tool, input_filename)
|
||||
golden.assertGolden(widget_to_string(result), golden_path)
|
||||
self.assertEqual(status, expected_status)
|
||||
|
||||
def test_metadata(self):
|
||||
mock_stat_result = unittest.mock.Mock(
|
||||
|
|
@ -59,57 +61,73 @@ class ToolsTestCase(unittest.TestCase):
|
|||
return_value=mock_stat_result):
|
||||
with unittest.mock.patch.object(tools.pwd, "getpwuid",
|
||||
return_value=mock_pw_entry):
|
||||
self._test_tool(tools.metadata, "hi3.py",
|
||||
tools.Status.normal)
|
||||
self._sub_tests([
|
||||
(tools.metadata, "hi3.py", tools.Status.normal)])
|
||||
|
||||
def test_contents(self):
|
||||
self._test_tool(tools.contents, "hi3.py", tools.Status.normal)
|
||||
self._sub_tests([(tools.contents, "hi3.py", tools.Status.normal)])
|
||||
|
||||
def test_python_syntax(self):
|
||||
self._test_tool(tools.python_syntax, "hi3.py", tools.Status.ok)
|
||||
self._sub_tests([(tools.python_syntax, "hi3.py", tools.Status.ok)])
|
||||
|
||||
def test_unittests(self):
|
||||
self._test_tool(tools.python_unittests, "hi3.py",
|
||||
tools.Status.not_applicable)
|
||||
self._sub_tests([
|
||||
(tools.python_unittests, "hi3.py", tools.Status.not_applicable)])
|
||||
|
||||
def test_pydoc(self):
|
||||
self._test_tool(tools.pydoc, "hi3.py", tools.Status.normal)
|
||||
self._sub_tests([(tools.pydoc, "hi3.py", tools.Status.normal)])
|
||||
|
||||
def test_python_coverage(self):
|
||||
self._test_tool(tools.python_coverage, "hi3.py", tools.Status.normal)
|
||||
self._sub_tests([
|
||||
(tools.python_coverage, "hi3.py", tools.Status.normal)])
|
||||
|
||||
def test_pep8(self):
|
||||
self._test_tool(tools.pep8, "hi3.py", tools.Status.ok)
|
||||
self._sub_tests([(tools.pep8, "hi3.py", tools.Status.ok)])
|
||||
|
||||
def test_pyflakes(self):
|
||||
self._test_tool(tools.pyflakes, "hi3.py", tools.Status.ok)
|
||||
self._sub_tests([(tools.pyflakes, "hi3.py", tools.Status.ok)])
|
||||
|
||||
def test_pylint(self):
|
||||
self._test_tool(tools.pylint, "hi3.py", tools.Status.ok)
|
||||
self._sub_tests([(tools.pylint, "hi3.py", tools.Status.ok)])
|
||||
|
||||
def test_python_gut(self):
|
||||
self._test_tool(tools.python_gut, "hi3.py", tools.Status.normal)
|
||||
self._sub_tests([(tools.python_gut, "hi3.py", tools.Status.normal)])
|
||||
|
||||
def test_python_modulefinder(self):
|
||||
self._test_tool(tools.python_modulefinder, "hi3.py",
|
||||
tools.Status.normal)
|
||||
self._sub_tests([
|
||||
(tools.python_modulefinder, "hi3.py", tools.Status.normal)])
|
||||
|
||||
def test_python_mccable(self):
|
||||
self._test_tool(tools.python_mccabe, "hi3.py", tools.Status.ok)
|
||||
self._sub_tests([(tools.python_mccabe, "hi3.py", tools.Status.ok)])
|
||||
|
||||
def test_perl_syntax(self):
|
||||
self._test_tool(tools.perl_syntax, "perl.pl", tools.Status.ok)
|
||||
self._sub_tests([(tools.perl_syntax, "perl.pl", tools.Status.ok)])
|
||||
|
||||
def test_perldoc(self):
|
||||
self._test_tool(tools.perldoc, "perl.pl",
|
||||
tools.Status.not_applicable)
|
||||
self._test_tool(tools.perldoc, "contents.pod", tools.Status.normal)
|
||||
self._sub_tests([
|
||||
(tools.perldoc, "perl.pl", tools.Status.not_applicable),
|
||||
(tools.perldoc, "contents.pod", tools.Status.normal)])
|
||||
|
||||
def test_perltidy(self):
|
||||
self._test_tool(tools.perltidy, "perl.pl", tools.Status.normal)
|
||||
self._sub_tests([(tools.perltidy, "perl.pl", tools.Status.normal)])
|
||||
|
||||
def test_perl6_syntax(self):
|
||||
self._test_tool(tools.perl6_syntax, "perl6.p6", tools.Status.problem)
|
||||
self._sub_tests([
|
||||
(tools.perl6_syntax, "perl6.p6", tools.Status.problem)])
|
||||
|
||||
def test_antic(self):
|
||||
self._sub_tests([
|
||||
(tools.antic, "closure-util.java", tools.Status.problem)])
|
||||
|
||||
def test_uncrustify(self):
|
||||
self._sub_tests([
|
||||
(tools.uncrustify, "closure-util.java", tools.Status.problem),
|
||||
(tools.uncrustify, "hello.c", tools.Status.normal),
|
||||
(tools.uncrustify, "hello.h", tools.Status.normal)])
|
||||
|
||||
def test_splint(self):
|
||||
self._sub_tests([(tools.splint, "hello.c", tools.Status.ok),
|
||||
(tools.splint, "hello.h", tools.Status.ok)])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue