def test_XMLOutputStream_createStdout(self): stream = libsbml.XMLOutputStream(libsbml.cout, "UTF-8", False) self.assert_(stream != None) _dummyList = [stream] _dummyList[:] = [] del _dummyList pass
def test_XMLOutputStream_createStdoutWithProgramInfo(self): stream = libsbml.XMLOutputStream(libsbml.cout, "UTF-8", False, "foo", "bar") self.assert_(stream != None) _dummyList = [stream] _dummyList[:] = [] del _dummyList pass
def test_XMLOutputStream_startEnd(self): oss = libsbml.ostringstream() stream = libsbml.XMLOutputStream(oss,"",False) self.assert_( stream != None ) stream.startEndElement( "id") str = oss.str() self.assert_(( "<id/>" == str )) _dummyList = [ stream ]; _dummyList[:] = []; del _dummyList pass
def test_XMLOutputStream_createStringWithProgramInfo(self): expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; oss = libsbml.ostringstream() stream = libsbml.XMLOutputStream(oss,"UTF-8",True, "", "") self.assert_( stream != None ) str = oss.str() self.assert_(( expected == str )) _dummyList = [ stream ]; _dummyList[:] = []; del _dummyList pass
def test_XMLOutputStream_PredefinedEntity(self): oss = libsbml.ostringstream() stream = libsbml.XMLOutputStream(oss,"",False) stream.startElement( "testpde") stream.writeAttribute( "amp", "&" ) stream.writeAttribute( "apos", "'" ) stream.writeAttribute( "gt", ">" ) stream.writeAttribute( "lt", "<" ) stream.writeAttribute( "quot", "\"" ) stream.writeAttribute( "pdeamp", "&" ) stream.writeAttribute( "pdeapos", "'") stream.writeAttribute( "pdegt", ">" ) stream.writeAttribute( "pdelt", "<" ) stream.writeAttribute( "pdequot", """) stream.endElement( "testpde") expected = "<testpde amp=\"&\" apos=\"'\" gt=\">\" lt=\"<\" quot=\""\" pdeamp=\"&\" pdeapos=\"'\" pdegt=\">\" pdelt=\"<\" pdequot=\""\"/>"; s = oss.str() self.assert_(( expected == s )) _dummyList = [ stream ]; _dummyList[:] = []; del _dummyList pass
def test_XMLOutputStream_Elements(self): d = 2.4 l = 123456789 ui = 5 i = -3 oss = libsbml.ostringstream() stream = libsbml.XMLOutputStream(oss,"",False) stream.startElement( "fred") stream.writeAttribute( "chars", "two") stream.writeAttributeBool( "bool",True) stream.writeAttribute( "double",d) stream.writeAttribute( "long",l) stream.writeAttribute( "uint",ui) stream.writeAttribute( "int",i) stream.endElement( "fred") expected = "<fred chars=\"two\" bool=\"true\" double=\"2.4\" long=\"123456789\" uint=\"5\" int=\"-3\"/>"; s = oss.str() self.assert_(( expected == s )) _dummyList = [ stream ]; _dummyList[:] = []; del _dummyList pass
def test_XMLOutputStream_CharacterReference(self): oss = libsbml.ostringstream() stream = libsbml.XMLOutputStream(oss,"",False) stream.startElement( "testcr") stream.writeAttribute( "chars", "one" ) stream.writeAttribute( "amp", "&" ) stream.writeAttribute( "deccr", "¨" ) stream.writeAttribute( "hexcr", "¨") stream.writeAttribute( "lhexcr", "¨") stream.writeAttribute( "nodeccr1", "ژ" ) stream.writeAttribute( "nodeccr2", "&#;" ) stream.writeAttribute( "nodeccr3", "�a8;" ) stream.writeAttribute( "nodeccr4", "�A8;" ) stream.writeAttribute( "nohexcr1", "&#x;" ) stream.writeAttribute( "nohexcr2", "ꯍ" ) stream.endElement( "testcr") expected = "<testcr chars=\"one\" amp=\"&\" deccr=\"¨\" hexcr=\"¨\" lhexcr=\"¨\" nodeccr1=\"&#01688\" nodeccr2=\"&#;\" nodeccr3=\"&#00a8;\" nodeccr4=\"&#00A8;\" nohexcr1=\"&#x;\" nohexcr2=\"&#xABCD\"/>"; s = oss.str() self.assert_(( expected == s )) _dummyList = [ stream ]; _dummyList[:] = []; del _dummyList pass