Updated SleekTest.streamClose to check that the stream was actually started before closing it.

Updated tests for Iq stanzas to not start a stream for every test; tests now run a lot faster.
The call to streamClose must still be in the tearDown method to ensure it is called in the
case of an error.
This commit is contained in:
Lance Stout 2010-08-11 18:41:57 -04:00
parent c09e9c702c
commit 7a5ef28492
2 changed files with 2 additions and 5 deletions

View file

@ -258,7 +258,7 @@ class SleekTest(unittest.TestCase):
self.checkPresence(data, sent, use_values) self.checkPresence(data, sent, use_values)
def streamClose(self): def streamClose(self):
if self.xmpp is not None: if hasattr(self, 'xmpp') and self.xmpp is not None:
self.xmpp.disconnect() self.xmpp.disconnect()
self.xmpp.socket.recvData(self.xmpp.stream_footer) self.xmpp.socket.recvData(self.xmpp.stream_footer)

View file

@ -4,10 +4,6 @@ from sleekxmpp.xmlstream.stanzabase import ET
class TestIqStanzas(SleekTest): class TestIqStanzas(SleekTest):
def setUp(self):
"""Start XML stream for testing."""
self.streamStart()
def tearDown(self): def tearDown(self):
"""Shutdown the XML stream after testing.""" """Shutdown the XML stream after testing."""
self.streamClose() self.streamClose()
@ -32,6 +28,7 @@ class TestIqStanzas(SleekTest):
def testUnhandled(self): def testUnhandled(self):
"""Test behavior for Iq.unhandled.""" """Test behavior for Iq.unhandled."""
self.streamStart()
self.streamRecv(""" self.streamRecv("""
<iq id="test" type="get"> <iq id="test" type="get">
<query xmlns="test" /> <query xmlns="test" />