Пример #1
0
 def test__enter____exit__(self):
     conn = BrokerConnection(backend_cls=Backend)
     context = conn.__enter__()
     self.assertIs(context, conn)
     conn.connect()
     self.assertTrue(conn.connection.connected)
     conn.__exit__()
     self.assertIsNone(conn.connection)
     conn.close() # again
Пример #2
0
 def test__enter____exit__(self):
     conn = BrokerConnection(transport=Transport)
     context = conn.__enter__()
     self.assertIs(context, conn)
     conn.connect()
     self.assertTrue(conn.connection.connected)
     conn.__exit__()
     self.assertIsNone(conn.connection)
     conn.close() # again