def test_from_cookie_list(self): cookie = create_cookie('foo', 'bar') mgr = CookieManager.from_cookie_list([cookie]) test_cookie = [x for x in mgr.cookiejar if x.name == 'foo'][0] self.assertEqual(cookie.name, test_cookie.name) mgr = CookieManager.from_cookie_list([]) self.assertEqual(0, len(list(mgr.cookiejar)))
def test_from_cookie_list(self): cookie = create_cookie("foo", "bar", self.server.address) mgr = CookieManager.from_cookie_list([cookie]) test_cookie = [x for x in mgr.cookiejar if x.name == "foo"][0] self.assertEqual(cookie.name, test_cookie.name) mgr = CookieManager.from_cookie_list([]) self.assertEqual(0, len(list(mgr.cookiejar)))
def test_from_cookie_list(self): cookie = create_cookie('foo', 'bar', self.server.address) mgr = CookieManager.from_cookie_list([cookie]) test_cookie = [x for x in mgr.cookiejar if x.name == 'foo'][0] self.assertEqual(cookie.name, test_cookie.name) mgr = CookieManager.from_cookie_list([]) self.assertEqual(0, len(list(mgr.cookiejar)))
def test_pickle_serialization(self): cookie = create_cookie('foo', 'bar') mgr = CookieManager.from_cookie_list([cookie]) dump = pickle.dumps(mgr) mgr2 = pickle.loads(dump) self.assertEqual(list(mgr.cookiejar)[0].value, list(mgr2.cookiejar)[0].value)
def test_pickle_serialization(self): cookie = create_cookie('foo', 'bar', self.server.address) mgr = CookieManager.from_cookie_list([cookie]) dump = pickle.dumps(mgr) mgr2 = pickle.loads(dump) self.assertEqual(list(mgr.cookiejar)[0].value, list(mgr2.cookiejar)[0].value)
def load_config(self, config): """ Configure grab instance with external config object. """ self.config = copy_config(config, self.mutable_config_keys) if 'cookiejar_cookies' in config['state']: self.cookies = CookieManager.from_cookie_list(config['state']['cookiejar_cookies'])
def load_config(self, config): """ Configure grab instance with external config object. """ self.config = copy_config(config, self.mutable_config_keys) if 'cookiejar_cookies' in config['state']: self.cookies = CookieManager.from_cookie_list( config['state']['cookiejar_cookies'])
def test_get_item(self): cookie = create_cookie("foo", "bar", self.server.address) mgr = CookieManager.from_cookie_list([cookie]) self.assertEqual("bar", mgr["foo"]) self.assertRaises(KeyError, lambda: mgr["zzz"])
def test_get_item(self): cookie = create_cookie('foo', 'bar', self.server.address) mgr = CookieManager.from_cookie_list([cookie]) self.assertEqual('bar', mgr['foo']) self.assertRaises(KeyError, lambda: mgr['zzz'])
def test_get_item(self): cookie = create_cookie('foo', 'bar') mgr = CookieManager.from_cookie_list([cookie]) self.assertEqual('bar', mgr['foo']) self.assertRaises(KeyError, lambda: mgr['zzz'])