Skip to content

Commit 4cce809

Browse files
committed
Progress on tests.
Signed-off-by: Mike Stitt <[email protected]>
1 parent acc7385 commit 4cce809

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

subprojects/robotpy-wpilib/tests/conftest.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
commands2 = None
2626

2727

28-
2928
@pytest.fixture
3029
def cfg_logging(caplog):
3130
caplog.set_level(logging.INFO)
@@ -50,8 +49,11 @@ def nt(cfg_logging, wpilib_state):
5049
instance.stopLocal()
5150
instance._reset()
5251

52+
5353
@pytest.fixture(scope="class", autouse=False)
54-
def physics_and_decorated_robot_class(myrobot_class, robots_sim_enable_physics)->tuple:
54+
def physics_and_decorated_robot_class(
55+
myrobot_class, robots_sim_enable_physics
56+
) -> tuple:
5557
# attach physics
5658

5759
robotClass = myrobot_class
@@ -74,13 +76,13 @@ def robotInit(self):
7476
finally:
7577
self.__robotInitialized()
7678

77-
7879
TestRobot.__name__ = robotClass.__name__
7980
TestRobot.__module__ = robotClass.__module__
8081
TestRobot.__qualname__ = robotClass.__qualname__
8182

8283
return (physicsInterface, TestRobot)
8384

85+
8486
@pytest.fixture(scope="function", autouse=False)
8587
def robot_with_sim_setup_teardown(physics_and_decorated_robot_class):
8688
"""
@@ -119,7 +121,7 @@ def robot_with_sim_setup_teardown(physics_and_decorated_robot_class):
119121
yield weakref.proxy(robot)
120122

121123
# If running in separate processes, no need to do cleanup
122-
#if ISOLATED:
124+
# if ISOLATED:
123125
# # .. and funny enough, in isolated mode we *don't* want the
124126
# # robot to be cleaned up, as that can deadlock
125127
# self._saved_robot = robot
@@ -167,9 +169,12 @@ def robot_with_sim_setup_teardown(physics_and_decorated_robot_class):
167169
# and functions will only be called the first time (unless re-registered)
168170
# hal.shutdown()
169171

172+
170173
@pytest.fixture(scope="function")
171-
def getTestController(reraise, robot_with_sim_setup_teardown: wpilib.RobotBase) -> TestController:
174+
def getTestController(
175+
reraise, robot_with_sim_setup_teardown: wpilib.RobotBase
176+
) -> TestController:
172177
"""
173178
A pytest fixture that provides control over your robot_with_sim_setup_teardown
174179
"""
175-
return TestController(reraise, robot_with_sim_setup_teardown)
180+
return TestController(reraise, robot_with_sim_setup_teardown)

subprojects/robotpy-wpilib/tests/test_poc_timedrobot.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def run_practice(control: "TestController"):
3131
# Run teleop + enabled for 2 minutes
3232
control.step_timing(seconds=120, autonomous=False, enabled=True)
3333

34-
class TestThings():
34+
35+
class TestThings:
3536

3637
class MyRobot(TimedRobotPy):
3738
def __init__(self):
@@ -46,7 +47,6 @@ def robotInit(self):
4647

4748
def robotPeriodic(self):
4849
self.robotPeriodicCount += 1
49-
print(f"in {self.__class__.__name__} periodic count={self.robotPeriodicCount}")
5050

5151
#########################################################
5252
## Autonomous-Specific init and update
@@ -93,7 +93,6 @@ def myrobot_class(cls) -> type[MyRobot]:
9393
def robots_sim_enable_physics(cls) -> bool:
9494
return False
9595

96-
9796
def test_iterative(self, getTestController, robot_with_sim_setup_teardown):
9897
"""Ensure that all states of the iterative robot run"""
9998
assert robot_with_sim_setup_teardown.robotInitialized == False

0 commit comments

Comments
 (0)