File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -469,6 +469,19 @@ def test_fail(self):
469469 """
470470 v = in_ ([1 , 2 , 3 ])
471471 a = simple_attr ("test" )
472+ with pytest .raises (ValueError ) as e :
473+ v (None , a , None )
474+ assert (
475+ "'test' must be in [1, 2, 3] (got None)" ,
476+ ) == e .value .args
477+
478+ def test_fail_verbose (self ):
479+ """
480+ Raise verbose ValueError if the value is outside our options
481+ and verbose_value_error is set to True.
482+ """
483+ v = in_ ([1 , 2 , 3 ], verbose_value_error = True )
484+ a = simple_attr ("test" )
472485 with pytest .raises (ValueError ) as e :
473486 v (None , a , None )
474487 assert (
@@ -485,6 +498,20 @@ def test_fail_with_string(self):
485498 """
486499 v = in_ ("abc" )
487500 a = simple_attr ("test" )
501+ with pytest .raises (ValueError ) as e :
502+ v (None , a , None )
503+ assert (
504+ "'test' must be in 'abc' (got None)" ,
505+ ) == e .value .args
506+
507+ def test_fail_with_string_verbose (self ):
508+ """
509+ Raise verbose ValueError if the value is outside our options when
510+ the options are specified as a string, verbose_value_error is set
511+ to True and the value is not a string.
512+ """
513+ v = in_ ("abc" , verbose_value_error = True )
514+ a = simple_attr ("test" )
488515 with pytest .raises (ValueError ) as e :
489516 v (None , a , None )
490517 assert (
You can’t perform that action at this time.
0 commit comments