@@ -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-
407409class 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+
611614class MyRobotSimulationInitFails (MyRobotDefaultPass ):
612615 @printEntryAndExit
613616 def _simulationInit (self ):
@@ -620,7 +623,6 @@ def _simulationPeriodic(self):
620623 assert False
621624
622625
623-
624626class ExpectFinished (Enum ):
625627 kNotFinished = 0
626628 kFinished = 1
@@ -650,9 +652,12 @@ def enabled(self):
650652
651653
652654from dataclasses import dataclass , field
655+
656+
653657@dataclass ()
654658class 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" )
700707def 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" ,
0 commit comments