-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconftest.py
50 lines (35 loc) · 1.08 KB
/
conftest.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
import os
import sys
from unittest.mock import MagicMock, PropertyMock
import pytest
from gym_gridverse.action import Action
from gym_gridverse.state import State
# avoid discovering tests in setup.py
collect_ignore = ["setup.py"]
# setup PYTHONPATH to allow import custom modules in yaml/
@pytest.fixture(scope='session', autouse=True)
def execute_before_tests():
base = os.path.dirname(__file__)
sys.path.append(f'{base}/yaml')
@pytest.fixture
def forbidden_state_maker():
grids = []
agents = []
def _forbidden_state_maker() -> State:
state = MagicMock()
type(state).grid = grid = PropertyMock()
type(state).agent = agent = PropertyMock()
grids.append(grid)
agents.append(agent)
return state
yield _forbidden_state_maker
for grid in grids:
grid.assert_not_called()
for agent in agents:
agent.assert_not_called()
@pytest.fixture
def forbidden_action_maker():
def _forbidden_action_maker() -> Action:
action = MagicMock()
return action
yield _forbidden_action_maker