PyCG 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- micro-benchmark/__init__.py +0 -0
- micro-benchmark/args_test.py +25 -0
- micro-benchmark/assignments_test.py +19 -0
- micro-benchmark/base.py +87 -0
- micro-benchmark/builtins_test.py +16 -0
- micro-benchmark/classes_test.py +73 -0
- micro-benchmark/create_pytests.py +42 -0
- micro-benchmark/decorators_test.py +28 -0
- micro-benchmark/dicts_test.py +43 -0
- micro-benchmark/direct_calls_test.py +19 -0
- micro-benchmark/dynamic_test.py +10 -0
- micro-benchmark/exceptions_test.py +16 -0
- micro-benchmark/external_test.py +25 -0
- micro-benchmark/functions_test.py +19 -0
- micro-benchmark/generators_test.py +25 -0
- micro-benchmark/imports_test.py +49 -0
- micro-benchmark/kwargs_test.py +16 -0
- micro-benchmark/lambdas_test.py +22 -0
- micro-benchmark/lists_test.py +31 -0
- micro-benchmark/mro_test.py +28 -0
- micro-benchmark/returns_test.py +19 -0
- micro-benchmark-key-errs/__init__.py +0 -0
- micro-benchmark-key-errs/assignments_test.py +16 -0
- micro-benchmark-key-errs/base.py +81 -0
- micro-benchmark-key-errs/classes_test.py +25 -0
- micro-benchmark-key-errs/create_pytests.py +42 -0
- micro-benchmark-key-errs/dicts_test.py +34 -0
- micro-benchmark-key-errs/kwargs_test.py +13 -0
- micro-benchmark-key-errs/lists_test.py +13 -0
- micro-benchmark-key-errs/parameters_test.py +16 -0
- pycg/__init__.py +0 -0
- pycg/__main__.py +104 -0
- pycg/formats/__init__.py +23 -0
- pycg/formats/as_graph.py +32 -0
- pycg/formats/base.py +23 -0
- pycg/formats/fasten.py +253 -0
- pycg/formats/simple.py +32 -0
- pycg/machinery/__init__.py +0 -0
- pycg/machinery/callgraph.py +59 -0
- pycg/machinery/classes.py +77 -0
- pycg/machinery/definitions.py +219 -0
- pycg/machinery/imports.py +220 -0
- pycg/machinery/key_err.py +34 -0
- pycg/machinery/modules.py +66 -0
- pycg/machinery/pointers.py +146 -0
- pycg/machinery/scopes.py +143 -0
- pycg/processing/__init__.py +0 -0
- pycg/processing/base.py +522 -0
- pycg/processing/cgprocessor.py +230 -0
- pycg/processing/keyerrprocessor.py +82 -0
- pycg/processing/postprocessor.py +308 -0
- pycg/processing/preprocessor.py +375 -0
- pycg/pycg.py +229 -0
- pycg/utils/__init__.py +22 -0
- pycg/utils/common.py +39 -0
- pycg/utils/constants.py +42 -0
- pycg-0.0.3.dist-info/LICENCE +201 -0
- pycg-0.0.3.dist-info/METADATA +150 -0
- pycg-0.0.3.dist-info/RECORD +62 -0
- pycg-0.0.3.dist-info/WHEEL +5 -0
- pycg-0.0.3.dist-info/entry_points.txt +3 -0
- pycg-0.0.3.dist-info/top_level.txt +3 -0
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class ArgsTest(TestBase):
|
|
7
|
+
snippet_dir = "args"
|
|
8
|
+
|
|
9
|
+
def test_nested_call(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("nested_call"))
|
|
11
|
+
|
|
12
|
+
def test_param_call(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("param_call"))
|
|
14
|
+
|
|
15
|
+
def test_assigned_call(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("assigned_call"))
|
|
17
|
+
|
|
18
|
+
def test_imported_call(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("imported_call"))
|
|
20
|
+
|
|
21
|
+
def test_imported_assigned_call(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("imported_assigned_call"))
|
|
23
|
+
|
|
24
|
+
def test_call(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("call"))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class AssignmentsTest(TestBase):
|
|
7
|
+
snippet_dir = "assignments"
|
|
8
|
+
|
|
9
|
+
def test_tuple(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("tuple"))
|
|
11
|
+
|
|
12
|
+
def test_chained(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("chained"))
|
|
14
|
+
|
|
15
|
+
def test_recursive_tuple(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("recursive_tuple"))
|
|
17
|
+
|
|
18
|
+
def test_starred(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("starred"))
|
micro-benchmark/base.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2020 Vitalis Salis.
|
|
3
|
+
#
|
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
5
|
+
# or more contributor license agreements. See the NOTICE file
|
|
6
|
+
# distributed with this work for additional information
|
|
7
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
8
|
+
# to you under the Apache License, Version 2.0 (the
|
|
9
|
+
# "License"); you may not use this file except in compliance
|
|
10
|
+
# with the License. You may obtain a copy of the License at
|
|
11
|
+
#
|
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
#
|
|
14
|
+
# Unless required by applicable law or agreed to in writing,
|
|
15
|
+
# software distributed under the License is distributed on an
|
|
16
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
17
|
+
# KIND, either express or implied. See the License for the
|
|
18
|
+
# specific language governing permissions and limitations
|
|
19
|
+
# under the License.
|
|
20
|
+
#
|
|
21
|
+
import os
|
|
22
|
+
import sys
|
|
23
|
+
import importlib
|
|
24
|
+
import json
|
|
25
|
+
|
|
26
|
+
from unittest import TestCase, main
|
|
27
|
+
from pycg import utils
|
|
28
|
+
|
|
29
|
+
class TestBase(TestCase):
|
|
30
|
+
snippet_dir = ""
|
|
31
|
+
|
|
32
|
+
def setUp(self):
|
|
33
|
+
def error():
|
|
34
|
+
print ("Invalid module %s.%s" % (cg_mod, cg_class))
|
|
35
|
+
print ("Set environment variables `CALL_GRAPH_CLASS` and `CALL_GRAPH_MODULE` properly")
|
|
36
|
+
sys.exit(1)
|
|
37
|
+
|
|
38
|
+
self.snippets_path = os.environ.get("SNIPPETS_PATH")
|
|
39
|
+
cg_class = os.environ.get('CALL_GRAPH_CLASS', None)
|
|
40
|
+
cg_mod = os.environ.get('CALL_GRAPH_MODULE', None)
|
|
41
|
+
if not cg_class or not cg_mod:
|
|
42
|
+
error()
|
|
43
|
+
try:
|
|
44
|
+
self.cg_mod = importlib.import_module(cg_mod)
|
|
45
|
+
except ImportError:
|
|
46
|
+
error()
|
|
47
|
+
|
|
48
|
+
self.cg_class = getattr(self.cg_mod, cg_class)
|
|
49
|
+
if not self.cg_class:
|
|
50
|
+
error()
|
|
51
|
+
|
|
52
|
+
def validate_snippet(self, snippet_path):
|
|
53
|
+
output = self.get_snippet_output_cg(snippet_path)
|
|
54
|
+
expected = self.get_snippet_expected_cg(snippet_path)
|
|
55
|
+
|
|
56
|
+
self.assertEqual(output, expected)
|
|
57
|
+
|
|
58
|
+
def get_snippet_path(self, name):
|
|
59
|
+
return os.path.join(self.snippets_path, self.snippet_dir, name)
|
|
60
|
+
|
|
61
|
+
def get_snippet_output_cg(self, snippet_path):
|
|
62
|
+
main_path = os.path.join(snippet_path, "main.py")
|
|
63
|
+
try:
|
|
64
|
+
cg = self.cg_class([main_path], snippet_path, -1, utils.constants.CALL_GRAPH_OP)
|
|
65
|
+
cg.analyze()
|
|
66
|
+
return cg.output()
|
|
67
|
+
except Exception as e:
|
|
68
|
+
cg.tearDown()
|
|
69
|
+
raise e
|
|
70
|
+
|
|
71
|
+
def get_snippet_expected_cg(self, snippet_path):
|
|
72
|
+
cg_path = os.path.join(snippet_path, "callgraph.json")
|
|
73
|
+
with open(cg_path, "r") as f:
|
|
74
|
+
return json.loads(f.read())
|
|
75
|
+
|
|
76
|
+
def assertEqual(self, actual, expected):
|
|
77
|
+
def do_sorted(d):
|
|
78
|
+
s = {}
|
|
79
|
+
for n in d:
|
|
80
|
+
s[n] = sorted(d[n])
|
|
81
|
+
return s
|
|
82
|
+
|
|
83
|
+
super().assertEqual(do_sorted(actual), do_sorted(expected))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if __name__ == "__main__":
|
|
87
|
+
main()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class BuiltinsTest(TestBase):
|
|
7
|
+
snippet_dir = "builtins"
|
|
8
|
+
|
|
9
|
+
def test_types(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("types"))
|
|
11
|
+
|
|
12
|
+
def test_map(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("map"))
|
|
14
|
+
|
|
15
|
+
def test_functions(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("functions"))
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class ClassesTest(TestBase):
|
|
7
|
+
snippet_dir = "classes"
|
|
8
|
+
|
|
9
|
+
def test_imported_call_without_init(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("imported_call_without_init"))
|
|
11
|
+
|
|
12
|
+
def test_direct_call(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("direct_call"))
|
|
14
|
+
|
|
15
|
+
def test_return_call_direct(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("return_call_direct"))
|
|
17
|
+
|
|
18
|
+
def test_nested_class_calls(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("nested_class_calls"))
|
|
20
|
+
|
|
21
|
+
def test_super_class_return(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("super_class_return"))
|
|
23
|
+
|
|
24
|
+
def test_base_class_calls_child(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("base_class_calls_child"))
|
|
26
|
+
|
|
27
|
+
def test_tuple_assignment(self):
|
|
28
|
+
self.validate_snippet(self.get_snippet_path("tuple_assignment"))
|
|
29
|
+
|
|
30
|
+
def test_return_call(self):
|
|
31
|
+
self.validate_snippet(self.get_snippet_path("return_call"))
|
|
32
|
+
|
|
33
|
+
def test_nested_call(self):
|
|
34
|
+
self.validate_snippet(self.get_snippet_path("nested_call"))
|
|
35
|
+
|
|
36
|
+
def test_imported_attr_access(self):
|
|
37
|
+
self.validate_snippet(self.get_snippet_path("imported_attr_access"))
|
|
38
|
+
|
|
39
|
+
def test_assigned_call(self):
|
|
40
|
+
self.validate_snippet(self.get_snippet_path("assigned_call"))
|
|
41
|
+
|
|
42
|
+
def test_self_assign_func(self):
|
|
43
|
+
self.validate_snippet(self.get_snippet_path("self_assign_func"))
|
|
44
|
+
|
|
45
|
+
def test_imported_call(self):
|
|
46
|
+
self.validate_snippet(self.get_snippet_path("imported_call"))
|
|
47
|
+
|
|
48
|
+
def test_base_class_attr(self):
|
|
49
|
+
self.validate_snippet(self.get_snippet_path("base_class_attr"))
|
|
50
|
+
|
|
51
|
+
def test_static_method_call(self):
|
|
52
|
+
self.validate_snippet(self.get_snippet_path("static_method_call"))
|
|
53
|
+
|
|
54
|
+
def test_call(self):
|
|
55
|
+
self.validate_snippet(self.get_snippet_path("call"))
|
|
56
|
+
|
|
57
|
+
def test_instance(self):
|
|
58
|
+
self.validate_snippet(self.get_snippet_path("instance"))
|
|
59
|
+
|
|
60
|
+
def test_imported_nested_attr_access(self):
|
|
61
|
+
self.validate_snippet(self.get_snippet_path("imported_nested_attr_access"))
|
|
62
|
+
|
|
63
|
+
def test_parameter_call(self):
|
|
64
|
+
self.validate_snippet(self.get_snippet_path("parameter_call"))
|
|
65
|
+
|
|
66
|
+
def test_self_assignment(self):
|
|
67
|
+
self.validate_snippet(self.get_snippet_path("self_assignment"))
|
|
68
|
+
|
|
69
|
+
def test_self_call(self):
|
|
70
|
+
self.validate_snippet(self.get_snippet_path("self_call"))
|
|
71
|
+
|
|
72
|
+
def test_assigned_self_call(self):
|
|
73
|
+
self.validate_snippet(self.get_snippet_path("assigned_self_call"))
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
FILE_DIR = os.path.dirname(os.path.relpath(__file__))
|
|
6
|
+
SNIPPETS_DIR = "snippets"
|
|
7
|
+
|
|
8
|
+
base_template = """
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
from base import TestBase
|
|
12
|
+
|
|
13
|
+
class {cls}Test(TestBase):
|
|
14
|
+
snippet_dir = "{dir}"
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
test_template = """
|
|
18
|
+
def test_{name}(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("{name}"))
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def create_test_case(name):
|
|
23
|
+
test_name = name + "_test.py"
|
|
24
|
+
# TODO: capitalize
|
|
25
|
+
capitalized = "".join([x.title() for x in name.split("_")])
|
|
26
|
+
template = base_template.format(
|
|
27
|
+
cls=capitalized,
|
|
28
|
+
dir=name
|
|
29
|
+
)
|
|
30
|
+
for name in os.listdir(os.path.join(FILE_DIR, SNIPPETS_DIR, name)):
|
|
31
|
+
if name == "." or name == "..":
|
|
32
|
+
continue
|
|
33
|
+
template += test_template.format(name=name)
|
|
34
|
+
|
|
35
|
+
with open(os.path.join(FILE_DIR, test_name), "w+") as f:
|
|
36
|
+
f.write(template)
|
|
37
|
+
|
|
38
|
+
for name in os.listdir(os.path.join(FILE_DIR, SNIPPETS_DIR)):
|
|
39
|
+
if name == "." or name == "..":
|
|
40
|
+
continue
|
|
41
|
+
|
|
42
|
+
create_test_case(name)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class DecoratorsTest(TestBase):
|
|
7
|
+
snippet_dir = "decorators"
|
|
8
|
+
|
|
9
|
+
def test_return_different_func(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("return_different_func"))
|
|
11
|
+
|
|
12
|
+
def test_param_call(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("param_call"))
|
|
14
|
+
|
|
15
|
+
def test_nested_decorators(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("nested_decorators"))
|
|
17
|
+
|
|
18
|
+
def test_assigned(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("assigned"))
|
|
20
|
+
|
|
21
|
+
def test_return(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("return"))
|
|
23
|
+
|
|
24
|
+
def test_call(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("call"))
|
|
26
|
+
|
|
27
|
+
def test_nested(self):
|
|
28
|
+
self.validate_snippet(self.get_snippet_path("nested"))
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class DictsTest(TestBase):
|
|
7
|
+
snippet_dir = "dicts"
|
|
8
|
+
|
|
9
|
+
def test_type_coercion(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("type_coercion"))
|
|
11
|
+
|
|
12
|
+
def test_update(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("update"))
|
|
14
|
+
|
|
15
|
+
def test_ext_key(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("ext_key"))
|
|
17
|
+
|
|
18
|
+
def test_return(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("return"))
|
|
20
|
+
|
|
21
|
+
def test_param(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("param"))
|
|
23
|
+
|
|
24
|
+
def test_return_assign(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("return_assign"))
|
|
26
|
+
|
|
27
|
+
def test_call(self):
|
|
28
|
+
self.validate_snippet(self.get_snippet_path("call"))
|
|
29
|
+
|
|
30
|
+
def test_assign(self):
|
|
31
|
+
self.validate_snippet(self.get_snippet_path("assign"))
|
|
32
|
+
|
|
33
|
+
def test_param_key(self):
|
|
34
|
+
self.validate_snippet(self.get_snippet_path("param_key"))
|
|
35
|
+
|
|
36
|
+
def test_new_key_param(self):
|
|
37
|
+
self.validate_snippet(self.get_snippet_path("new_key_param"))
|
|
38
|
+
|
|
39
|
+
def test_nested(self):
|
|
40
|
+
self.validate_snippet(self.get_snippet_path("nested"))
|
|
41
|
+
|
|
42
|
+
def test_add_key(self):
|
|
43
|
+
self.validate_snippet(self.get_snippet_path("add_key"))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class DirectCallsTest(TestBase):
|
|
7
|
+
snippet_dir = "direct_calls"
|
|
8
|
+
|
|
9
|
+
def test_with_parameters(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("with_parameters"))
|
|
11
|
+
|
|
12
|
+
def test_imported_return_call(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("imported_return_call"))
|
|
14
|
+
|
|
15
|
+
def test_return_call(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("return_call"))
|
|
17
|
+
|
|
18
|
+
def test_assigned_call(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("assigned_call"))
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class ExceptionsTest(TestBase):
|
|
7
|
+
snippet_dir = "exceptions"
|
|
8
|
+
|
|
9
|
+
def test_raise(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("raise"))
|
|
11
|
+
|
|
12
|
+
def test_raise_attr(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("raise_attr"))
|
|
14
|
+
|
|
15
|
+
def test_raise_assigned(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("raise_assigned"))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class ExternalTest(TestBase):
|
|
7
|
+
snippet_dir = "external"
|
|
8
|
+
|
|
9
|
+
def test_attribute(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("attribute"))
|
|
11
|
+
|
|
12
|
+
def test_function_assigned(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("function_assigned"))
|
|
14
|
+
|
|
15
|
+
def test_attribute_assigned(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("attribute_assigned"))
|
|
17
|
+
|
|
18
|
+
def test_function_asname(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("function_asname"))
|
|
20
|
+
|
|
21
|
+
def test_function(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("function"))
|
|
23
|
+
|
|
24
|
+
def test_cls_parent(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("cls_parent"))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class FunctionsTest(TestBase):
|
|
7
|
+
snippet_dir = "functions"
|
|
8
|
+
|
|
9
|
+
def test_assigned_call(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("assigned_call"))
|
|
11
|
+
|
|
12
|
+
def test_imported_call(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("imported_call"))
|
|
14
|
+
|
|
15
|
+
def test_call(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("call"))
|
|
17
|
+
|
|
18
|
+
def test_assigned_call_lit_param(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("assigned_call_lit_param"))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class GeneratorsTest(TestBase):
|
|
7
|
+
snippet_dir = "generators"
|
|
8
|
+
|
|
9
|
+
def test_iter_param(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("iter_param"))
|
|
11
|
+
|
|
12
|
+
def test_no_iter(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("no_iter"))
|
|
14
|
+
|
|
15
|
+
def test_iter_return(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("iter_return"))
|
|
17
|
+
|
|
18
|
+
def test_iterable(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("iterable"))
|
|
20
|
+
|
|
21
|
+
def test_iterable_assigned(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("iterable_assigned"))
|
|
23
|
+
|
|
24
|
+
def test_yield(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("yield"))
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class ImportsTest(TestBase):
|
|
7
|
+
snippet_dir = "imports"
|
|
8
|
+
|
|
9
|
+
def test_relative_import_with_name(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("relative_import_with_name"))
|
|
11
|
+
|
|
12
|
+
def test_submodule_import_from(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("submodule_import_from"))
|
|
14
|
+
|
|
15
|
+
def test_import_as(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("import_as"))
|
|
17
|
+
|
|
18
|
+
def test_submodule_import_all(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("submodule_import_all"))
|
|
20
|
+
|
|
21
|
+
def test_parent_import(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("parent_import"))
|
|
23
|
+
|
|
24
|
+
def test_chained_import(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("chained_import"))
|
|
26
|
+
|
|
27
|
+
def test_init_func_import(self):
|
|
28
|
+
self.validate_snippet(self.get_snippet_path("init_func_import"))
|
|
29
|
+
|
|
30
|
+
def test_submodule_import_as(self):
|
|
31
|
+
self.validate_snippet(self.get_snippet_path("submodule_import_as"))
|
|
32
|
+
|
|
33
|
+
def test_relative_import(self):
|
|
34
|
+
self.validate_snippet(self.get_snippet_path("relative_import"))
|
|
35
|
+
|
|
36
|
+
def test_import_all(self):
|
|
37
|
+
self.validate_snippet(self.get_snippet_path("import_all"))
|
|
38
|
+
|
|
39
|
+
def test_simple_import(self):
|
|
40
|
+
self.validate_snippet(self.get_snippet_path("simple_import"))
|
|
41
|
+
|
|
42
|
+
def test_init_import(self):
|
|
43
|
+
self.validate_snippet(self.get_snippet_path("init_import"))
|
|
44
|
+
|
|
45
|
+
def test_submodule_import(self):
|
|
46
|
+
self.validate_snippet(self.get_snippet_path("submodule_import"))
|
|
47
|
+
|
|
48
|
+
def test_import_from(self):
|
|
49
|
+
self.validate_snippet(self.get_snippet_path("import_from"))
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class KwargsTest(TestBase):
|
|
7
|
+
snippet_dir = "kwargs"
|
|
8
|
+
|
|
9
|
+
def test_chained_call(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("chained_call"))
|
|
11
|
+
|
|
12
|
+
def test_assigned_call(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("assigned_call"))
|
|
14
|
+
|
|
15
|
+
def test_call(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("call"))
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class LambdasTest(TestBase):
|
|
7
|
+
snippet_dir = "lambdas"
|
|
8
|
+
|
|
9
|
+
def test_calls_parameter(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("calls_parameter"))
|
|
11
|
+
|
|
12
|
+
def test_return_call(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("return_call"))
|
|
14
|
+
|
|
15
|
+
def test_call(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("call"))
|
|
17
|
+
|
|
18
|
+
def test_parameter_call(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("parameter_call"))
|
|
20
|
+
|
|
21
|
+
def test_chained_calls(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("chained_calls"))
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class ListsTest(TestBase):
|
|
7
|
+
snippet_dir = "lists"
|
|
8
|
+
|
|
9
|
+
def test_comprehension_val(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("comprehension_val"))
|
|
11
|
+
|
|
12
|
+
def test_slice(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("slice"))
|
|
14
|
+
|
|
15
|
+
def test_simple(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("simple"))
|
|
17
|
+
|
|
18
|
+
def test_comprehension_if(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("comprehension_if"))
|
|
20
|
+
|
|
21
|
+
def test_nested_comprehension(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("nested_comprehension"))
|
|
23
|
+
|
|
24
|
+
def test_param_index(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("param_index"))
|
|
26
|
+
|
|
27
|
+
def test_nested(self):
|
|
28
|
+
self.validate_snippet(self.get_snippet_path("nested"))
|
|
29
|
+
|
|
30
|
+
def test_ext_index(self):
|
|
31
|
+
self.validate_snippet(self.get_snippet_path("ext_index"))
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class MroTest(TestBase):
|
|
7
|
+
snippet_dir = "mro"
|
|
8
|
+
|
|
9
|
+
def test_basic_init(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("basic_init"))
|
|
11
|
+
|
|
12
|
+
def test_parents_same_superclass(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("parents_same_superclass"))
|
|
14
|
+
|
|
15
|
+
def test_basic(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("basic"))
|
|
17
|
+
|
|
18
|
+
def test_two_parents(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("two_parents"))
|
|
20
|
+
|
|
21
|
+
def test_super_call(self):
|
|
22
|
+
self.validate_snippet(self.get_snippet_path("super_call"))
|
|
23
|
+
|
|
24
|
+
def test_self_assignment(self):
|
|
25
|
+
self.validate_snippet(self.get_snippet_path("self_assignment"))
|
|
26
|
+
|
|
27
|
+
def test_two_parents_method_defined(self):
|
|
28
|
+
self.validate_snippet(self.get_snippet_path("two_parents_method_defined"))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class ReturnsTest(TestBase):
|
|
7
|
+
snippet_dir = "returns"
|
|
8
|
+
|
|
9
|
+
def test_return_complex(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("return_complex"))
|
|
11
|
+
|
|
12
|
+
def test_imported_call(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("imported_call"))
|
|
14
|
+
|
|
15
|
+
def test_nested_import_call(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("nested_import_call"))
|
|
17
|
+
|
|
18
|
+
def test_call(self):
|
|
19
|
+
self.validate_snippet(self.get_snippet_path("call"))
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from base import TestBase
|
|
5
|
+
|
|
6
|
+
class AssignmentsTest(TestBase):
|
|
7
|
+
snippet_dir = "assignments"
|
|
8
|
+
|
|
9
|
+
def test_chained(self):
|
|
10
|
+
self.validate_snippet(self.get_snippet_path("chained"))
|
|
11
|
+
|
|
12
|
+
def test_recursive_tuple(self):
|
|
13
|
+
self.validate_snippet(self.get_snippet_path("recursive_tuple"))
|
|
14
|
+
|
|
15
|
+
def test_starred(self):
|
|
16
|
+
self.validate_snippet(self.get_snippet_path("starred"))
|