Coding style.
This commit is contained in:
parent
39859cd49e
commit
ecf4d8216d
1 changed files with 67 additions and 73 deletions
140
tools_test.py
140
tools_test.py
|
|
@ -43,8 +43,8 @@ def run_tool(tool, input_filename):
|
||||||
|
|
||||||
class ToolsTestCase(unittest.TestCase):
|
class ToolsTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def _sub_tests(self, sub_tests):
|
def _test_tool(self, tool, sub_tests):
|
||||||
for tool, input_filename, expected_status in sub_tests:
|
for input_filename, expected_status in sub_tests:
|
||||||
with self.subTest(input_filename=input_filename):
|
with self.subTest(input_filename=input_filename):
|
||||||
status, result = run_tool(tool, input_filename)
|
status, result = run_tool(tool, input_filename)
|
||||||
golden_path = result_path(tool, input_filename)
|
golden_path = result_path(tool, input_filename)
|
||||||
|
|
@ -61,136 +61,130 @@ class ToolsTestCase(unittest.TestCase):
|
||||||
return_value=mock_stat_result):
|
return_value=mock_stat_result):
|
||||||
with unittest.mock.patch.object(tools.pwd, "getpwuid",
|
with unittest.mock.patch.object(tools.pwd, "getpwuid",
|
||||||
return_value=mock_pw_entry):
|
return_value=mock_pw_entry):
|
||||||
self._sub_tests([
|
self._test_tool(tools.metadata,
|
||||||
(tools.metadata, "hi3.py", tools.Status.normal)])
|
[("hi3.py", tools.Status.normal)])
|
||||||
|
|
||||||
def test_contents(self):
|
def test_contents(self):
|
||||||
self._sub_tests([(tools.contents, "hi3.py", tools.Status.normal)])
|
self._test_tool(tools.contents, [("hi3.py", tools.Status.normal)])
|
||||||
|
|
||||||
def test_python_syntax(self):
|
def test_python_syntax(self):
|
||||||
self._sub_tests([(tools.python_syntax, "hi3.py", tools.Status.ok),
|
self._test_tool(tools.python_syntax, [("hi3.py", tools.Status.ok),
|
||||||
(tools.python_syntax, "hi.py", tools.Status.ok)])
|
("hi.py", tools.Status.ok)])
|
||||||
|
|
||||||
def test_unittests(self):
|
def test_unittests(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.python_unittests,
|
||||||
(tools.python_unittests, "hi3.py", tools.Status.not_applicable),
|
[("hi3.py", tools.Status.not_applicable),
|
||||||
(tools.python_unittests, "hi.py", tools.Status.not_applicable)])
|
("hi.py", tools.Status.not_applicable)])
|
||||||
|
|
||||||
def test_pydoc(self):
|
def test_pydoc(self):
|
||||||
self._sub_tests([(tools.pydoc, "hi3.py", tools.Status.normal),
|
self._test_tool(tools.pydoc, [("hi3.py", tools.Status.normal),
|
||||||
(tools.pydoc, "hi.py", tools.Status.normal)])
|
("hi.py", tools.Status.normal)])
|
||||||
|
|
||||||
def test_python_coverage(self):
|
def test_python_coverage(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.python_coverage,
|
||||||
(tools.python_coverage, "hi3.py", tools.Status.normal),
|
[("hi3.py", tools.Status.normal),
|
||||||
(tools.python_coverage, "hi.py", tools.Status.normal)])
|
("hi.py", tools.Status.normal)])
|
||||||
|
|
||||||
def test_pep8(self):
|
def test_pep8(self):
|
||||||
self._sub_tests([(tools.pep8, "hi3.py", tools.Status.ok),
|
self._test_tool(tools.pep8, [("hi3.py", tools.Status.ok),
|
||||||
(tools.pep8, "hi.py", tools.Status.ok)])
|
("hi.py", tools.Status.ok)])
|
||||||
|
|
||||||
def test_pyflakes(self):
|
def test_pyflakes(self):
|
||||||
self._sub_tests([(tools.pyflakes, "hi3.py", tools.Status.ok),
|
self._test_tool(tools.pyflakes, [("hi3.py", tools.Status.ok),
|
||||||
(tools.pyflakes, "hi.py", tools.Status.ok)])
|
("hi.py", tools.Status.ok)])
|
||||||
|
|
||||||
def test_pylint(self):
|
def test_pylint(self):
|
||||||
self._sub_tests([(tools.pylint, "hi3.py", tools.Status.ok),
|
self._test_tool(tools.pylint, [("hi3.py", tools.Status.ok),
|
||||||
(tools.pylint, "hi.py", tools.Status.ok)])
|
("hi.py", tools.Status.ok)])
|
||||||
|
|
||||||
def test_python_gut(self):
|
def test_python_gut(self):
|
||||||
self._sub_tests([(tools.python_gut, "hi3.py", tools.Status.normal),
|
self._test_tool(tools.python_gut, [("hi3.py", tools.Status.normal),
|
||||||
(tools.python_gut, "hi.py", tools.Status.normal)])
|
("hi.py", tools.Status.normal)])
|
||||||
|
|
||||||
def test_python_modulefinder(self):
|
def test_python_modulefinder(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.python_modulefinder,
|
||||||
(tools.python_modulefinder, "hi3.py", tools.Status.normal),
|
[("hi3.py", tools.Status.normal),
|
||||||
(tools.python_modulefinder, "hi.py", tools.Status.normal)])
|
("hi.py", tools.Status.normal)])
|
||||||
|
|
||||||
def test_python_mccable(self):
|
def test_python_mccable(self):
|
||||||
self._sub_tests([(tools.python_mccabe, "hi3.py", tools.Status.ok),
|
self._test_tool(tools.python_mccabe, [("hi3.py", tools.Status.ok),
|
||||||
(tools.python_mccabe, "hi.py", tools.Status.ok)])
|
("hi.py", tools.Status.ok)])
|
||||||
|
|
||||||
def test_perl_syntax(self):
|
def test_perl_syntax(self):
|
||||||
self._sub_tests([(tools.perl_syntax, "perl.pl", tools.Status.ok)])
|
self._test_tool(tools.perl_syntax, [("perl.pl", tools.Status.ok)])
|
||||||
|
|
||||||
def test_perldoc(self):
|
def test_perldoc(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.perldoc,
|
||||||
(tools.perldoc, "perl.pl", tools.Status.not_applicable),
|
[("perl.pl", tools.Status.not_applicable),
|
||||||
(tools.perldoc, "contents.pod", tools.Status.normal)])
|
("contents.pod", tools.Status.normal)])
|
||||||
|
|
||||||
def test_perltidy(self):
|
def test_perltidy(self):
|
||||||
self._sub_tests([(tools.perltidy, "perl.pl", tools.Status.normal)])
|
self._test_tool(tools.perltidy, [("perl.pl", tools.Status.normal)])
|
||||||
|
|
||||||
def test_perl6_syntax(self):
|
def test_perl6_syntax(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.perl6_syntax,
|
||||||
(tools.perl6_syntax, "perl6.p6", tools.Status.problem)])
|
[("perl6.p6", tools.Status.problem)])
|
||||||
|
|
||||||
def test_antic(self):
|
def test_antic(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.antic,
|
||||||
(tools.antic, "closure-util.java", tools.Status.problem)])
|
[("closure-util.java", tools.Status.problem)])
|
||||||
|
|
||||||
def test_jlint(self):
|
def test_jlint(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.jlint, [("javaversion.class", tools.Status.ok)])
|
||||||
(tools.jlint, "javaversion.class", tools.Status.ok)])
|
|
||||||
|
|
||||||
def test_uncrustify(self):
|
def test_uncrustify(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.uncrustify,
|
||||||
(tools.uncrustify, "closure-util.java", tools.Status.problem),
|
[("closure-util.java", tools.Status.problem),
|
||||||
(tools.uncrustify, "hello.c", tools.Status.normal),
|
("hello.c", tools.Status.normal),
|
||||||
(tools.uncrustify, "hello.h", tools.Status.normal),
|
("hello.h", tools.Status.normal),
|
||||||
(tools.uncrustify, "hello.cpp", tools.Status.normal)])
|
("hello.cpp", tools.Status.normal)])
|
||||||
|
|
||||||
def test_splint(self):
|
def test_splint(self):
|
||||||
self._sub_tests([(tools.splint, "hello.c", tools.Status.ok),
|
self._test_tool(tools.splint, [("hello.c", tools.Status.ok),
|
||||||
(tools.splint, "hello.h", tools.Status.ok)])
|
("hello.h", tools.Status.ok)])
|
||||||
|
|
||||||
def test_object_file_tools(self):
|
def test_objdump_headers(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.objdump_headers,
|
||||||
(tools.objdump_headers, "Mcrt1.o", tools.Status.normal),
|
[("Mcrt1.o", tools.Status.normal)])
|
||||||
(tools.objdump_disassemble, "Mcrt1.o", tools.Status.problem),
|
|
||||||
(tools.readelf, "Mcrt1.o", tools.Status.normal)])
|
def test_objdump_disassemble(self):
|
||||||
|
self._test_tool(tools.objdump_disassemble,
|
||||||
|
[("Mcrt1.o", tools.Status.problem)])
|
||||||
|
|
||||||
|
def test_readelf(self):
|
||||||
|
self._test_tool(tools.readelf, [("Mcrt1.o", tools.Status.normal)])
|
||||||
|
|
||||||
def test_unzip(self):
|
def test_unzip(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.unzip, [("hi.zip", tools.Status.normal)])
|
||||||
(tools.unzip, "hi.zip", tools.Status.normal)])
|
|
||||||
|
|
||||||
def test_tar_gz(self):
|
def test_tar_gz(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.tar_gz, [("hi.tar.gz", tools.Status.normal),
|
||||||
(tools.tar_gz, "hi.tar.gz", tools.Status.normal),
|
("hi.tgz", tools.Status.normal)])
|
||||||
(tools.tar_gz, "hi.tgz", tools.Status.normal)])
|
|
||||||
|
|
||||||
def test_tar_bz2(self):
|
def test_tar_bz2(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.tar_bz2, [("hi.tar.bz2", tools.Status.normal)])
|
||||||
(tools.tar_bz2, "hi.tar.bz2", tools.Status.normal)])
|
|
||||||
|
|
||||||
def test_nm(self):
|
def test_nm(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.nm, [("libieee.a", tools.Status.normal),
|
||||||
(tools.nm, "libieee.a", tools.Status.normal),
|
("libpcprofile.so", tools.Status.normal)])
|
||||||
(tools.nm, "libpcprofile.so", tools.Status.normal)])
|
|
||||||
|
|
||||||
def test_pdf2txt(self):
|
def test_pdf2txt(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.pdf2txt, [("standard.pdf", tools.Status.normal)])
|
||||||
(tools.pdf2txt, "standard.pdf", tools.Status.normal)])
|
|
||||||
|
|
||||||
def test_html_syntax(self):
|
def test_html_syntax(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.html_syntax, [("hi.html", tools.Status.problem)])
|
||||||
(tools.html_syntax, "hi.html", tools.Status.problem)])
|
|
||||||
|
|
||||||
def test_tidy(self):
|
def test_tidy(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.tidy, [("hi.html", tools.Status.normal)])
|
||||||
(tools.tidy, "hi.html", tools.Status.normal)])
|
|
||||||
|
|
||||||
def test_html2text(self):
|
def test_html2text(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.html2text, [("hi.html", tools.Status.normal)])
|
||||||
(tools.html2text, "hi.html", tools.Status.normal)])
|
|
||||||
|
|
||||||
def test_bcpp(self):
|
def test_bcpp(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.bcpp, [("hello.cpp", tools.Status.normal)])
|
||||||
(tools.bcpp, "hello.cpp", tools.Status.normal)])
|
|
||||||
|
|
||||||
def test_php5_syntax(self):
|
def test_php5_syntax(self):
|
||||||
self._sub_tests([
|
self._test_tool(tools.bcpp, [("root.php", tools.Status.normal)])
|
||||||
(tools.bcpp, "root.php", tools.Status.normal)])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue