@@ -376,7 +376,9 @@ def startCompetition(self) -> None:
376
376
hasAssertionError = True
377
377
378
378
# 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
+ )
380
382
381
383
if False :
382
384
# Print the stack trace
@@ -388,7 +390,9 @@ def startCompetition(self) -> None:
388
390
389
391
except Exception as e :
390
392
# 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
+ )
392
396
393
397
# Print the stack trace
394
398
print ("Stack trace:" )
@@ -402,8 +406,6 @@ def startCompetition(self) -> None:
402
406
assert hasAssertionError
403
407
404
408
405
-
406
-
407
409
class TimedRobotPyDoNotExpectException (TimedRobotPy ):
408
410
409
411
def __init__ (self , period = TimedRobotPy .kDefaultPeriod ):
@@ -608,6 +610,7 @@ class MyRobotTestExitFails(MyRobotDefaultPass):
608
610
def testExit (self ):
609
611
assert False
610
612
613
+
611
614
class MyRobotSimulationInitFails (MyRobotDefaultPass ):
612
615
@printEntryAndExit
613
616
def _simulationInit (self ):
@@ -620,7 +623,6 @@ def _simulationPeriodic(self):
620
623
assert False
621
624
622
625
623
-
624
626
class ExpectFinished (Enum ):
625
627
kNotFinished = 0
626
628
kFinished = 1
@@ -650,9 +652,12 @@ def enabled(self):
650
652
651
653
652
654
from dataclasses import dataclass , field
655
+
656
+
653
657
@dataclass ()
654
658
class CaseConfiguration :
655
659
"""Class for configuration of Test Cases"""
660
+
656
661
description : str
657
662
myRobotAddMethods : type
658
663
timedRobotExpectation : TimedRobotPy
@@ -673,7 +678,9 @@ def myrobot_class(
673
678
print (f"expectFinished={ caseConfiguration .expectFinished } " )
674
679
print (f"callSequenceStr={ caseConfiguration .callSequenceStr } \n \n " )
675
680
676
- class MyRobot (caseConfiguration .myRobotAddMethods , caseConfiguration .timedRobotExpectation ):
681
+ class MyRobot (
682
+ caseConfiguration .myRobotAddMethods , caseConfiguration .timedRobotExpectation
683
+ ):
677
684
678
685
@printEntryAndExit
679
686
def startCompetition (self ):
@@ -692,14 +699,15 @@ def expect_finished(caseConfiguration) -> bool:
692
699
693
700
694
701
@pytest .fixture (scope = "function" )
695
- def robot_mode_fixture (caseConfiguration )-> RobotMode :
702
+ def robot_mode_fixture (caseConfiguration ) -> RobotMode :
696
703
return caseConfiguration .robotMode
697
704
698
705
699
706
@pytest .fixture (scope = "function" )
700
707
def call_sequence_str (caseConfiguration ) -> str :
701
708
return caseConfiguration .callSequenceStr
702
709
710
+
703
711
@pytest .mark .filterwarnings ("ignore:Exception in thread" )
704
712
@pytest .mark .parametrize (
705
713
"caseConfiguration" ,
@@ -772,7 +780,7 @@ def call_sequence_str(caseConfiguration) -> str:
772
780
expectFinished = ExpectFinished .kNotFinished ,
773
781
robotMode = RobotMode .kAutonomous ,
774
782
callSequenceStr = ":startCompetition+:robotInit+:robotInit-:_simulationInit+:_simulationInit-"
775
- ":disabledInit+:disabledInit-:disabledPeriodic+:disabledPeriodic-:robotPeriodic+:"
783
+ ":disabledInit+:disabledInit-:disabledPeriodic+:disabledPeriodic-:robotPeriodic+:" ,
776
784
),
777
785
CaseConfiguration (
778
786
description = "Robot enters autonomous mode, exception in simulationPeriodic" ,
@@ -791,7 +799,7 @@ def call_sequence_str(caseConfiguration) -> str:
791
799
expectFinished = ExpectFinished .kNotFinished ,
792
800
robotMode = RobotMode .kAutonomous ,
793
801
callSequenceStr = ":startCompetition+:robotInit+:robotInit-:_simulationInit+:_simulationInit-"
794
- ":disabledInit+:"
802
+ ":disabledInit+:" ,
795
803
),
796
804
CaseConfiguration (
797
805
description = "Robot enters autonomous mode, exception in disabledPeriodic" ,
@@ -800,7 +808,7 @@ def call_sequence_str(caseConfiguration) -> str:
800
808
expectFinished = ExpectFinished .kNotFinished ,
801
809
robotMode = RobotMode .kAutonomous ,
802
810
callSequenceStr = ":startCompetition+:robotInit+:robotInit-:_simulationInit+:_simulationInit-"
803
- ":disabledInit+:disabledInit-:disabledPeriodic+:"
811
+ ":disabledInit+:disabledInit-:disabledPeriodic+:" ,
804
812
),
805
813
CaseConfiguration (
806
814
description = "Robot enters autonomous mode, exception in disabledExit" ,
0 commit comments