def setUp(self): super(ZKServiceGroupTestCase, self).setUp() servicegroup.API._driver = None self.flags(servicegroup_driver='zk') self.flags(address='localhost:2181', group="zookeeper") try: zk.ZooKeeperDriver() except ImportError: self.skipTest("Unable to test due to lack of ZooKeeper")
def test_lazy_session(self): """Session object (contains zk handle) should be created in lazy manner, because handle cannot be shared by forked processes. """ # insied import because this test runs conditionaly (look at setUp) import evzookeeper driver = zk.ZooKeeperDriver() # check that internal private attribute session is empty self.assertIsNone(driver.__dict__['_ZooKeeperDriver__session']) # after first use of property ... driver._session # check that internal private session attribute is ready self.assertIsInstance(driver.__dict__['_ZooKeeperDriver__session'], evzookeeper.ZKSession)