-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestutil.py
53 lines (36 loc) · 1.07 KB
/
testutil.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
50
51
52
53
from gameconfig import game_config
from playercontrol import PlayerControl
class BrythonFunctionsMock:
def __init__(self, validation):
self.validation = validation
def hide(self, _):
pass
def show(self, _):
pass
@staticmethod
def using_idlist(*valid_ids):
def validation(eid):
return eid in valid_ids
return BrythonFunctionsMock(validation)
@staticmethod
def accepting_anything():
return BrythonFunctionsMock(lambda eid: True)
def get_element(self, eid):
if self.validation(eid):
return ElementMock(eid)
raise KeyError()
class ElementMock:
def __init__(self, eid):
def nop(_):
pass
self.text = eid
self.value = eid
self.classList = ClassListMock()
class ClassListMock:
def add(self, _):
pass
def remove(self, _):
pass
def create_player_control_mock(nr=0):
brython_functions = BrythonFunctionsMock.accepting_anything()
return PlayerControl(nr, game_config, brython_functions)