diff --git a/TODO b/TODO index af6733f..f2c6001 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ Todo -- Test the tools. - Publish. pypi and github will do. - docs?, setup.py?, wheel?, __pkginfo__.py? - Maybe also use cxfreeze, py2exe, pyrun or zipapp? Is zipapp the standard way? @@ -159,7 +158,8 @@ Done - Don't let the user scroll indefinately below the end of the page. - Add command line options, e.g. -h - Boilerplate: Readme, usage - +- Test the tools. + <- All the existing tools now have basic tests. A-syntax, B-tests, C-auto docs, D-lint, E-coverage, F-profile, G-tidy, H-import deps A B C D E F G H diff --git a/golden-files/input/hi3.cpython-34.pyc b/golden-files/input/hi3.cpython-34.pyc new file mode 100644 index 0000000..ee2fac4 Binary files /dev/null and b/golden-files/input/hi3.cpython-34.pyc differ diff --git a/tools.py b/tools.py index 3fb69b8..d8e7d3f 100644 --- a/tools.py +++ b/tools.py @@ -396,7 +396,8 @@ def python_tidy(path): # Deps: found on internet? def disassemble_pyc(path): - bytecode = open(path, "rb").read() + with open(path, "rb") as file_: + bytecode = file_.read() stringio = io.StringIO() dis.dis(bytecode, file=stringio) stringio.seek(0) diff --git a/tools_test.py b/tools_test.py index b4c036d..54829f5 100755 --- a/tools_test.py +++ b/tools_test.py @@ -106,6 +106,10 @@ class ToolsTestCase(unittest.TestCase): def test_python_mccable(self): self._test_tool(tools.python_mccabe, self.HI_OK) + def test_disassemble_pyc(self): + self._test_tool(tools.disassemble_pyc, + [("hi3.cpython-34.pyc", tools.Status.normal)]) + def test_perl_syntax(self): self._test_tool(tools.perl_syntax, [("perl.pl", tools.Status.ok)])