#NEWLINE# def test_literal( ) : #NEWLINE# #INDENT# ' test with Literal ' #NEWLINE# schema = Schema ( [ Literal ( { #NEWLINE# #INDENT# 'a' : 1 , #NEWLINE# #UNINDENT# } ) , Literal ( { #NEWLINE# #INDENT# 'b' : 1 , #NEWLINE# #UNINDENT# } ) ] ) #NEWLINE# schema ( [ { #NEWLINE# #INDENT# 'a' : 1 , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# schema ( [ { #NEWLINE# #INDENT# 'b' : 1 , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# schema ( [ { #NEWLINE# #INDENT# 'a' : 1 , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'b' : 1 , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# try : #NEWLINE# #INDENT# schema ( [ { #NEWLINE# #INDENT# 'c' : 1 , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# #UNINDENT# except Invalid as e : #NEWLINE# #INDENT# assert_equal ( str ( e ) , "{'c': 1} not match for {'b': 1} @ data[0]" ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , 'Did not raise Invalid' #NEWLINE# #UNINDENT# schema = Schema ( Literal ( { #NEWLINE# #INDENT# 'a' : 1 , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# try : #NEWLINE# #INDENT# schema ( { #NEWLINE# #INDENT# 'b' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except MultipleInvalid as e : #NEWLINE# #INDENT# assert_equal ( str ( schema ) , "{'b': 1} not match for {'a': 1}" ) #NEWLINE# assert_equal ( len ( e . errors ) , 1 ) #NEWLINE# assert_equal ( type ( e . errors [ 0 ] ) , LiteralInvalid ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , 'Did not raise Invalid'