| 1 |
# |
| 2 |
# written by Stefano Sanfilippo <[email protected]> |
| 3 |
# |
| 4 |
|
| 5 |
"""Tests for MyObfuscate unpacker.""" |
| 6 |
|
| 7 |
import unittest |
| 8 |
import os |
| 9 |
from jsbeautifier.unpackers.myobfuscate import detect, unpack |
| 10 |
from jsbeautifier.unpackers.tests import __path__ as path |
| 11 |
|
| 12 |
INPUT = os.path.join(path[0], "test-myobfuscate-input.js") |
| 13 |
OUTPUT = os.path.join(path[0], "test-myobfuscate-output.js") |
| 14 |
|
| 15 |
# pylint: disable=R0904 |
| 16 |
|
| •17 |
@unittest.skip("missing files") |
| 18 |
class TestMyObfuscate(unittest.TestCase): |
| 19 |
# pylint: disable=C0103 |
| 20 |
"""MyObfuscate obfuscator testcase.""" |
| 21 |
|
| 22 |
@classmethod |
| 23 |
def setUpClass(cls): |
| 24 |
"""Load source files (encoded and decoded version) for tests.""" |
| 25 |
with open(INPUT) as data: |
| 26 |
cls.input = data.read() |
| 27 |
with open(OUTPUT) as data: |
| 28 |
cls.output = data.read() |
| 29 |
|
| 30 |
def test_detect(self): |
| 31 |
"""Test detect() function.""" |
| 32 |
|
| 33 |
def detected(source): |
| 34 |
return self.assertTrue(detect(source)) |
| 35 |
|
| 36 |
detected(self.input) |
| 37 |
|
| 38 |
def test_unpack(self): |
| 39 |
"""Test unpack() function.""" |
| 40 |
|
| 41 |
def check(inp, out): |
| 42 |
return self.assertEqual(unpack(inp), out) |
| 43 |
|
| 44 |
check(self.input, self.output) |
| 45 |
|
| 46 |
|
| 47 |
if __name__ == "__main__": |
| 48 |
unittest.main() |