-
Notifications
You must be signed in to change notification settings - Fork 854
Expand file tree
/
Copy pathtest_code_modified_function.py
More file actions
36 lines (28 loc) · 1.2 KB
/
Copy pathtest_code_modified_function.py
File metadata and controls
36 lines (28 loc) · 1.2 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
import talon
if hasattr(talon, "test_mode"):
from unittest.mock import MagicMock
from talon import actions
def setup_function():
# Load our code under test (register code_* actions)
import lang.tags.functions # noqa: F401
actions.reset_test_actions()
def test_calls_expected_function():
"""
Test that the given combination of modifiers ends up delegating to the
correct function
"""
examples = [
(0, "code_default_function"),
(["static"], "code_private_static_function"),
(["private"], "code_private_function"),
(["private", "static"], "code_private_static_function"),
(["protected"], "code_protected_function"),
(["protected", "static"], "code_protected_static_function"),
(["public"], "code_public_function"),
(["public", "static"], "code_public_static_function"),
]
for modifiers, target_action in examples:
mock = MagicMock()
actions.register_test_action("user", target_action, mock)
talon.actions.user.code_modified_function(modifiers, "test func")
mock.assert_called_once()