def test_args(self): """initialization arguments for Session""" s = self.session self.assertTrue(s.pack is ss.default_packer) self.assertTrue(s.unpack is ss.default_unpacker) self.assertEquals(s.username, os.environ.get('USER', 'username')) s = ss.Session() self.assertEquals(s.username, os.environ.get('USER', 'username')) self.assertRaises(TypeError, ss.Session, pack='hi') self.assertRaises(TypeError, ss.Session, unpack='hi') u = str(uuid.uuid4()) s = ss.Session(username='******', session=u) self.assertEquals(s.session, u) self.assertEquals(s.username, 'carrot')
def test_session_id(self): session = ss.Session() # get bs before us bs = session.bsession us = session.session self.assertEquals(us.encode('ascii'), bs) session = ss.Session() # get us before bs us = session.session bs = session.bsession self.assertEquals(us.encode('ascii'), bs) # change propagates: session.session = 'something else' bs = session.bsession us = session.session self.assertEquals(us.encode('ascii'), bs) session = ss.Session(session='stuff') # get us before bs self.assertEquals(session.bsession, session.session.encode('ascii')) self.assertEquals(b'stuff', session.bsession)
def setUp(self): BaseZMQTestCase.setUp(self) self.session = ss.Session()