#NEWLINE# def test_length_validator( self ) : #NEWLINE# #INDENT# with pytest . raises ( ValueError ) : #NEWLINE# #INDENT# Length ( ( - 1 ) ) #NEWLINE# #UNINDENT# with pytest . raises ( ValueError ) : #NEWLINE# #INDENT# Length ( 0 ) #NEWLINE# #UNINDENT# passes = { #NEWLINE# #INDENT# 'foo' : [ Required , Length ( 5 ) , Length ( 1 , maximum = 5 ) ] , #NEWLINE# 'bar' : [ Required , Length ( 0 , maximum = 10 ) ] , #NEWLINE# #UNINDENT# } #NEWLINE# fails = { #NEWLINE# #INDENT# 'foo' : [ Required , Length ( 8 ) , Length ( 1 , maximum = 11 ) ] , #NEWLINE# 'bar' : [ Required , Length ( 0 , maximum = 3 ) ] , #NEWLINE# #UNINDENT# } #NEWLINE# test_case = { #NEWLINE# #INDENT# 'foo' : '12345' , #NEWLINE# 'bar' : [ 1 , 2 , 3 , 4 , 5 ] , #NEWLINE# #UNINDENT# } #NEWLINE# assert validate ( passes , fails ) [ 0 ] #NEWLINE# assert ( not validate ( fails , test_case ) [ 0 ] )