forked from rocky/python-uncompyle6
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_disasm.py-notyet
More file actions
33 lines (27 loc) · 911 Bytes
/
test_disasm.py-notyet
File metadata and controls
33 lines (27 loc) · 911 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
28
29
30
31
32
33
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", "function_to_test"), [
(
('../test/bytecode_2.7/05_if.pyc', 'testdata/if-2.7.right',),
disassemble_file
),
(
('../test/bytecode_2.7/05_ifelse.pyc', 'testdata/ifelse-2.7.right',),
disassemble_file
),
])
def test_funcoutput(capfd, test_tuple, function_to_test):
in_file , filename_expected = test_tuple
function_to_test(in_file, native=False)
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