forked from rocky/python-uncompyle6
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_disasm.py
More file actions
27 lines (21 loc) · 774 Bytes
/
test_disasm.py
File metadata and controls
27 lines (21 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os.path
import pytest
from uncompyle6.disas import disassemble_file
def get_srcdir():
filename = os.path.normcase(os.path.dirname(__file__))
return os.path.realpath(filename)
src_dir = get_srcdir()
os.chdir(src_dir)
@pytest.mark.parametrize(("test_tuple"), [
('../test/bytecode_2.7/05_if.pyc', 'testdata/if-2.7.right',),
('../test/bytecode_2.7/05_ifelse.pyc', 'testdata/ifelse-2.7.right',),
])
def test_funcoutput(capfd, test_tuple):
in_file, filename_expected = test_tuple
disassemble_file(in_file)
resout, reserr = capfd.readouterr()
expected = open(filename_expected, "r").read()
if resout != expected:
with open(filename_expected + ".got", "w") as out:
out.write(resout)
assert resout == expected