#NEWLINE# def test_export_level( models ) : #NEWLINE# #INDENT# ( M , N ) = models #NEWLINE# m_level = M . _options . export_level #NEWLINE# n_level = N . _options . export_level #NEWLINE# output = M ( input , init = False ) . to_primitive ( ) #NEWLINE# if ( ( m_level == NONEMPTY ) and ( n_level == NONEMPTY ) ) : #NEWLINE# #INDENT# assert ( output == { #NEWLINE# #INDENT# 'field1' : 'foo' , #NEWLINE# 'field2' : '' , #NEWLINE# 'field6' : None , #NEWLINE# 'modelfield1' : { #NEWLINE# #INDENT# 'subfield1' : 'foo' , #NEWLINE# 'subfield2' : '' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( m_level == NOT_NONE ) and ( n_level == NOT_NONE ) ) : #NEWLINE# #INDENT# assert ( output == { #NEWLINE# #INDENT# 'field1' : 'foo' , #NEWLINE# 'field2' : '' , #NEWLINE# 'field6' : None , #NEWLINE# 'listfield' : [ ] , #NEWLINE# 'modelfield1' : { #NEWLINE# #INDENT# 'subfield1' : 'foo' , #NEWLINE# 'subfield2' : '' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'modelfield2' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( m_level == DEFAULT ) and ( models == DEFAULT ) ) : #NEWLINE# #INDENT# assert ( output == { #NEWLINE# #INDENT# 'field1' : 'foo' , #NEWLINE# 'field2' : '' , #NEWLINE# 'field3' : None , #NEWLINE# 'field6' : None , #NEWLINE# 'listfield' : [ ] , #NEWLINE# 'modelfield1' : { #NEWLINE# #INDENT# 'subfield1' : 'foo' , #NEWLINE# 'subfield2' : '' , #NEWLINE# 'subfield3' : None , #NEWLINE# #UNINDENT# } , #NEWLINE# 'modelfield2' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( m_level == ALL ) and ( n_level == ALL ) ) : #NEWLINE# #INDENT# assert ( output == { #NEWLINE# #INDENT# 'field1' : 'foo' , #NEWLINE# 'field2' : '' , #NEWLINE# 'field3' : None , #NEWLINE# 'field4' : None , #NEWLINE# 'field6' : None , #NEWLINE# 'listfield' : [ ] , #NEWLINE# 'modelfield1' : { #NEWLINE# #INDENT# 'subfield1' : 'foo' , #NEWLINE# 'subfield2' : '' , #NEWLINE# 'subfield3' : None , #NEWLINE# 'subfield4' : None , #NEWLINE# #UNINDENT# } , #NEWLINE# 'modelfield2' : { #NEWLINE# #INDENT# 'subfield1' : None , #NEWLINE# 'subfield2' : None , #NEWLINE# 'subfield3' : None , #NEWLINE# 'subfield4' : None , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( m_level == DEFAULT ) and ( n_level == ALL ) ) : #NEWLINE# #INDENT# assert ( output == { #NEWLINE# #INDENT# 'field1' : 'foo' , #NEWLINE# 'field2' : '' , #NEWLINE# 'field3' : None , #NEWLINE# 'field6' : None , #NEWLINE# 'listfield' : [ ] , #NEWLINE# 'modelfield1' : { #NEWLINE# #INDENT# 'subfield1' : 'foo' , #NEWLINE# 'subfield2' : '' , #NEWLINE# 'subfield3' : None , #NEWLINE# 'subfield4' : None , #NEWLINE# #UNINDENT# } , #NEWLINE# 'modelfield2' : { #NEWLINE# #INDENT# 'subfield1' : None , #NEWLINE# 'subfield2' : None , #NEWLINE# 'subfield3' : None , #NEWLINE# 'subfield4' : None , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Assertions missing for testcase m_level={0}, n_level={1}' . format ( m_level , n_level ) )