mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-26 22:50:40 +00:00
28 lines
774 B
Python
28 lines
774 B
Python
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
|