1010def validator ():
1111 return SubplotidValidator ("prop" , "parent" , dflt = "geo" )
1212
13+
1314@pytest .fixture ()
1415def validator_aok ():
1516 return SubplotidValidator ("prop" , "parent" , dflt = "legend" , array_ok = True )
1617
18+
1719# Tests
1820
1921# Array not ok (default)
2022
2123# Acceptance
2224
25+
2326@pytest .mark .parametrize ("val" , ["geo" ] + ["geo%d" % i for i in range (2 , 10 )])
2427def test_acceptance (val , validator ):
2528 assert validator .validate_coerce (val ) == val
@@ -49,11 +52,15 @@ def test_rejection_value(val, validator):
4952
5053 assert "Invalid value" in str (validation_failure .value )
5154
55+
5256# Array ok
5357
5458# Acceptance
5559
56- @pytest .mark .parametrize ("val" , ["legend2" , ["legend" , "legend2" ], ("legend1" , "legend2" )])
60+
61+ @pytest .mark .parametrize (
62+ "val" , ["legend2" , ["legend" , "legend2" ], ("legend1" , "legend2" )]
63+ )
5764def test_acceptance_aok (val , validator_aok ):
5865 v = validator_aok .validate_coerce (val )
5966 if isinstance (val , tuple ):
@@ -80,12 +87,12 @@ def test_rejection_type_aok(val, validator_aok):
8087 "bogus" , # Must begin with 'geo'
8188 "legend0" , # If followed by a number the number must be > 1,
8289 ["" , "legend" ],
83- ("bogus" , "legend2" )
90+ ("bogus" , "legend2" ),
8491 ],
8592)
8693def test_rejection_value_aok (val , validator_aok ):
8794 with pytest .raises (ValueError ) as validation_failure :
8895 validator_aok .validate_coerce (val )
8996
9097 failure_msg = str (validation_failure .value )
91- assert "Invalid value" in failure_msg or "Invalid elements" in failure_msg
98+ assert "Invalid value" in failure_msg or "Invalid elements" in failure_msg
0 commit comments