Skip to content

Commit fcfd3ac

Browse files
committed
Run black.
Signed-off-by: Mike Stitt <mike@stitt.cc>
1 parent 557514d commit fcfd3ac

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

subprojects/robotpy-wpilib/tests/test_timedrobot.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ def startCompetition(self) -> None:
376376
hasAssertionError = True
377377

378378
# Print the exception type and message
379-
print(f"TimedRobotPyExpectsException AssertionError: Exception caught: {type(e).__name__}: {e}")
379+
print(
380+
f"TimedRobotPyExpectsException AssertionError: Exception caught: {type(e).__name__}: {e}"
381+
)
380382

381383
if False:
382384
# Print the stack trace
@@ -388,7 +390,9 @@ def startCompetition(self) -> None:
388390

389391
except Exception as e:
390392
# Print the exception type and message
391-
print(f"TimedRobotPyExpectsException Exception caught: {type(e).__name__}: {e}")
393+
print(
394+
f"TimedRobotPyExpectsException Exception caught: {type(e).__name__}: {e}"
395+
)
392396

393397
# Print the stack trace
394398
print("Stack trace:")
@@ -402,8 +406,6 @@ def startCompetition(self) -> None:
402406
assert hasAssertionError
403407

404408

405-
406-
407409
class TimedRobotPyDoNotExpectException(TimedRobotPy):
408410

409411
def __init__(self, period=TimedRobotPy.kDefaultPeriod):
@@ -608,6 +610,7 @@ class MyRobotTestExitFails(MyRobotDefaultPass):
608610
def testExit(self):
609611
assert False
610612

613+
611614
class MyRobotSimulationInitFails(MyRobotDefaultPass):
612615
@printEntryAndExit
613616
def _simulationInit(self):
@@ -620,7 +623,6 @@ def _simulationPeriodic(self):
620623
assert False
621624

622625

623-
624626
class ExpectFinished(Enum):
625627
kNotFinished = 0
626628
kFinished = 1
@@ -650,9 +652,12 @@ def enabled(self):
650652

651653

652654
from dataclasses import dataclass, field
655+
656+
653657
@dataclass()
654658
class CaseConfiguration:
655659
"""Class for configuration of Test Cases"""
660+
656661
description: str
657662
myRobotAddMethods: type
658663
timedRobotExpectation: TimedRobotPy
@@ -673,7 +678,9 @@ def myrobot_class(
673678
print(f"expectFinished={caseConfiguration.expectFinished}")
674679
print(f"callSequenceStr={caseConfiguration.callSequenceStr}\n\n")
675680

676-
class MyRobot(caseConfiguration.myRobotAddMethods, caseConfiguration.timedRobotExpectation):
681+
class MyRobot(
682+
caseConfiguration.myRobotAddMethods, caseConfiguration.timedRobotExpectation
683+
):
677684

678685
@printEntryAndExit
679686
def startCompetition(self):
@@ -692,14 +699,15 @@ def expect_finished(caseConfiguration) -> bool:
692699

693700

694701
@pytest.fixture(scope="function")
695-
def robot_mode_fixture(caseConfiguration)-> RobotMode:
702+
def robot_mode_fixture(caseConfiguration) -> RobotMode:
696703
return caseConfiguration.robotMode
697704

698705

699706
@pytest.fixture(scope="function")
700707
def call_sequence_str(caseConfiguration) -> str:
701708
return caseConfiguration.callSequenceStr
702709

710+
703711
@pytest.mark.filterwarnings("ignore:Exception in thread")
704712
@pytest.mark.parametrize(
705713
"caseConfiguration",
@@ -772,7 +780,7 @@ def call_sequence_str(caseConfiguration) -> str:
772780
expectFinished=ExpectFinished.kNotFinished,
773781
robotMode=RobotMode.kAutonomous,
774782
callSequenceStr=":startCompetition+:robotInit+:robotInit-:_simulationInit+:_simulationInit-"
775-
":disabledInit+:disabledInit-:disabledPeriodic+:disabledPeriodic-:robotPeriodic+:"
783+
":disabledInit+:disabledInit-:disabledPeriodic+:disabledPeriodic-:robotPeriodic+:",
776784
),
777785
CaseConfiguration(
778786
description="Robot enters autonomous mode, exception in simulationPeriodic",
@@ -791,7 +799,7 @@ def call_sequence_str(caseConfiguration) -> str:
791799
expectFinished=ExpectFinished.kNotFinished,
792800
robotMode=RobotMode.kAutonomous,
793801
callSequenceStr=":startCompetition+:robotInit+:robotInit-:_simulationInit+:_simulationInit-"
794-
":disabledInit+:"
802+
":disabledInit+:",
795803
),
796804
CaseConfiguration(
797805
description="Robot enters autonomous mode, exception in disabledPeriodic",
@@ -800,7 +808,7 @@ def call_sequence_str(caseConfiguration) -> str:
800808
expectFinished=ExpectFinished.kNotFinished,
801809
robotMode=RobotMode.kAutonomous,
802810
callSequenceStr=":startCompetition+:robotInit+:robotInit-:_simulationInit+:_simulationInit-"
803-
":disabledInit+:disabledInit-:disabledPeriodic+:"
811+
":disabledInit+:disabledInit-:disabledPeriodic+:",
804812
),
805813
CaseConfiguration(
806814
description="Robot enters autonomous mode, exception in disabledExit",

subprojects/robotpy-wpilib/wpilib/timedrobotpy.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def __contains__(self, item) -> bool:
178178
def __repr__(self) -> str:
179179
return str(sorted(self._data))
180180

181+
181182
# Hooks to use timeit to evaluate configurations of TimedRobotPy
182183
_OrderedList = _OrderedListMin
183184
_initializeNotifier = initializeNotifier
@@ -188,7 +189,7 @@ def __repr__(self) -> str:
188189
_stopNotifier = stopNotifier
189190
_report = report
190191
_IterativeRobotPy = IterativeRobotPy
191-
if '_IterativeRobotPyIsObject' in argv:
192+
if "_IterativeRobotPyIsObject" in argv:
192193
print("_IterativeRobotPyIsObject")
193194
_IterativeRobotPy = object
194195

@@ -310,9 +311,7 @@ def _bodyOfMainLoop(self) -> bool:
310311
# Process all other callbacks that are ready to run
311312
# Changing the comparison to be _getFPGATime() rather than
312313
# self._loopStartTimeUs would also be correct.
313-
while (
314-
callback := self._callbacks.peek()
315-
).expirationUs <= _getFPGATime():
314+
while (callback := self._callbacks.peek()).expirationUs <= _getFPGATime():
316315
self._runCallbackAtHeadOfListAndReschedule(callback)
317316

318317
return keepGoing

0 commit comments

Comments
 (0)