@@ -538,13 +538,6 @@ def setUpClass(cls):
538
538
# super call creates internal client cls.client
539
539
super (UnifiedSpecTestMixinV1 , cls ).setUpClass ()
540
540
541
- # process schemaVersion
542
- version = Version .from_string (cls .TEST_SPEC ['schemaVersion' ])
543
- if not version <= cls .SCHEMA_VERSION :
544
- raise unittest .SkipTest (
545
- 'expected schemaVersion %s or lower, got %s' % (
546
- cls .SCHEMA_VERSION , version ))
547
-
548
541
# process file-level runOnRequirements
549
542
run_on_spec = cls .TEST_SPEC .get ('runOnRequirements' , [])
550
543
if not cls .should_run_on (run_on_spec ):
@@ -559,6 +552,15 @@ def tearDownClass(cls):
559
552
def setUp (self ):
560
553
super (UnifiedSpecTestMixinV1 , self ).setUp ()
561
554
555
+ # process schemaVersion
556
+ # note: we check major schema version during class generation
557
+ # note: we do this here because we cannot run assertions in setUpClass
558
+ version = Version .from_string (self .TEST_SPEC ['schemaVersion' ])
559
+ self .assertLessEqual (
560
+ version , self .SCHEMA_VERSION ,
561
+ 'expected schema version %s or lower, got %s' % (
562
+ self .SCHEMA_VERSION , version ))
563
+
562
564
# initialize internals
563
565
self .match_evaluator = MatchEvaluatorUtil (self )
564
566
@@ -977,23 +979,17 @@ class SpecTestBase(with_metaclass(UnifiedSpecTestMeta)):
977
979
test_type .replace ('-' , '_' ).replace ('.' , '_' ))
978
980
class_name = snake_to_camel (snake_class_name )
979
981
980
- try :
981
- schema_version = Version .from_string (
982
- scenario_def ['schemaVersion' ])
983
- mixin_class = _SCHEMA_VERSION_MAJOR_TO_MIXIN_CLASS .get (
984
- schema_version [0 ])
985
- if mixin_class is None :
986
- print ('Ignoring test file %s with '
987
- 'unsupported schemaVersion %s' %
988
- (fpath , schema_version ))
989
- continue
990
- test_klasses [class_name ] = type (
991
- class_name ,
992
- (mixin_class , test_base_class_factory (scenario_def ),),
993
- {'__module__' : module })
994
- except (AttributeError , KeyError , TypeError ):
995
- print ("Ignoring invalid test file '%s'\n "
996
- "Original exception: %s" %
997
- (fpath , traceback .format_exc ()))
982
+ schema_version = Version .from_string (
983
+ scenario_def ['schemaVersion' ])
984
+ mixin_class = _SCHEMA_VERSION_MAJOR_TO_MIXIN_CLASS .get (
985
+ schema_version [0 ])
986
+ if mixin_class is None :
987
+ raise ValueError (
988
+ "test file '%s' has unsupported schemaVersion '%s'" % (
989
+ fpath , schema_version ))
990
+ test_klasses [class_name ] = type (
991
+ class_name ,
992
+ (mixin_class , test_base_class_factory (scenario_def ),),
993
+ {'__module__' : module })
998
994
999
995
return test_klasses
0 commit comments