-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_accurate_usage_detection.py
49 lines (36 loc) · 1.2 KB
/
test_accurate_usage_detection.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from unittest import skip
from deadcode.cli import main
from deadcode.utils.base_test_case import BaseTestCase
@skip
class TestAccurateUsageDetection(BaseTestCase):
def test_function_call_with_one_argument(self):
## TODO:
# Variable types should be tracked in each scope
# When scope changes during call: parameter types should be mapped from arguments
# When new type is defined: during import or definition: scope has to be updated.
self.files = {
'foo.py': b"""
class X:
def used_method(self):
pass
x = X()
def foo(y):
y.used_method()
foo(x)
"""
}
unused_names = main(['foo.py', '--no-color', '--fix'])
self.assertIsNone(unused_names)
self.assertFiles(
{
'foo.py': b"""
class X:
def used_method(self):
pass
x = X()
def foo(y):
y.used_method()
foo(x)
"""
}
)