forked from dflook/python-minifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_remove_object.py
More file actions
70 lines (55 loc) · 1.45 KB
/
test_remove_object.py
File metadata and controls
70 lines (55 loc) · 1.45 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import ast
import sys
import pytest
from python_minifier.ast_compare import compare_ast
from python_minifier.transforms.remove_object_base import RemoveObject
def test_remove_object_py3():
if sys.version_info < (3, 0):
pytest.skip('This test is python3 only')
source = '''
class Test(object):
pass
'''
expected = '''
class Test:
pass
'''
expected_ast = ast.parse(expected)
actual_ast = RemoveObject()(ast.parse(source))
compare_ast(expected_ast, actual_ast)
source = '''
class Test(another_base, object, third_base):
pass
'''
expected = '''
class Test(another_base, third_base):
pass
'''
expected_ast = ast.parse(expected)
actual_ast = RemoveObject()(ast.parse(source))
compare_ast(expected_ast, actual_ast)
expected_ast = ast.parse(expected)
actual_ast = RemoveObject()(ast.parse(source))
compare_ast(expected_ast, actual_ast)
source = '''
class Test(other_base):
pass
'''
expected = source
expected_ast = ast.parse(expected)
actual_ast = RemoveObject()(ast.parse(source))
compare_ast(expected_ast, actual_ast)
def test_no_remove_object_py2():
if sys.version_info >= (3, 0):
pytest.skip('This test is python2 only')
source = '''
class Test(object):
pass
'''
expected = '''
class Test(object):
pass
'''
expected_ast = ast.parse(expected)
actual_ast = RemoveObject()(ast.parse(source))
compare_ast(expected_ast, actual_ast)