-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathutil.py
52 lines (34 loc) · 1.04 KB
/
util.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
import commands2
from wpilib.simulation import DriverStationSim, pauseTiming, resumeTiming, stepTiming
# from unittest.mock import MagicMock
class ManualSimTime:
def __enter__(self) -> "ManualSimTime":
pauseTiming()
return self
def __exit__(self, *args):
resumeTiming()
def step(self, delta: float):
stepTiming(delta)
class CommandTestHelper:
def __init__(self) -> None:
self.scheduler = commands2.CommandScheduler.getInstance()
def __enter__(self):
commands2.CommandScheduler.resetInstance()
DriverStationSim.setEnabled(True)
return self
def __exit__(self, *args):
pass
class Counter:
def __init__(self) -> None:
self.value = 0
def increment(self):
self.value += 1
class ConditionHolder:
def __init__(self, cond: bool = False) -> None:
self.cond = cond
def getCondition(self) -> bool:
return self.cond
def setTrue(self):
self.cond = True
class TestSubsystem(commands2.SubsystemBase):
pass