-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
34 lines (30 loc) · 1.03 KB
/
test.py
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
34
import unittest
from six import StringIO
import os
import sys
from repyexe.decompile import decompile_exe
class Test(unittest.TestCase):
pass
def checkdecompile(filename):
outfile = StringIO()
decompile_exe(samplepath + filename, outstream=outfile)
outfile.seek(0)
content = outfile.read()
with open(answerpath + filename.split('.')[0], "r") as f:
answer = f.read()
return content.endswith(answer)
def test_generator(filename):
def test(self):
self.assertTrue(checkdecompile(filename))
return test
if __name__ == '__main__':
print("Testing Python {}.{}".format(sys.version_info.major, sys.version_info.minor))
sys.stdout = open(os.devnull, 'w')
version = "python{}{}/".format(sys.version_info.major, sys.version_info.minor)
samplepath = "samples/" + version
answerpath = "testcases/" + version
for filename in os.listdir(samplepath):
test_name = "test_{}".format(filename)
test = test_generator(filename)
setattr(Test, test_name, test)
unittest.main()