#NEWLINE# @ silence_warnings #NEWLINE# def test_user_provided_ns( self ) : #NEWLINE# #INDENT# 'Test that user-provided namespaces are serialized.\n\n        ' #NEWLINE# p = STIXPackage ( ) #NEWLINE# nsinfo = nsparser . NamespaceInfo ( ) #NEWLINE# nsinfo . collect ( p ) #NEWLINE# TEST_PREFIX = 'test' #NEWLINE# TEST_NS = 'a:unit:test' #NEWLINE# NEW_STIX_PREFIX = 'newstix' #NEWLINE# NEW_STIX_NS = 'http://stix.mitre.org/stix-1' #NEWLINE# test_dict = { #NEWLINE# #INDENT# TEST_NS : TEST_PREFIX , #NEWLINE# NEW_STIX_NS : NEW_STIX_PREFIX , #NEWLINE# #UNINDENT# } #NEWLINE# finalized = nsinfo . _finalize_namespaces ( ns_dict = test_dict ) #NEWLINE# nsinfo . finalized_namespaces #NEWLINE# self . assertEqual ( finalized . get ( TEST_PREFIX ) , TEST_NS ) #NEWLINE# self . assertEqual ( finalized . get ( NEW_STIX_PREFIX ) , NEW_STIX_NS ) #NEWLINE# xml = p . to_xml ( ns_dict = test_dict ) #NEWLINE# e = lxml . etree . XML ( xml ) #NEWLINE# self . assertEqual ( e . nsmap . get ( TEST_PREFIX ) , TEST_NS ) #NEWLINE# self . assertEqual ( e . nsmap . get ( NEW_STIX_PREFIX ) , NEW_STIX_NS )