def test_remove_with_multiple_proxies_overwrite_fallback_prevention(self): selector = ProxySelector(prevent_fallback=True) selector._proxy = self.user_proxy selector._proxy_list = self.proxy_list self.assertTrue(selector.remove_proxy(self.proxy_list[0])) self.assertEqual(selector._proxy, self.user_proxy) self.assertEqual(selector._proxy_list, ["8.8.8.8:2"]) self.assertTrue(selector.remove_proxy(self.user_proxy)) self.assertIsNone(selector._proxy) self.assertEqual(selector._proxy_list, ["8.8.8.8:2"]) self.assertFalse(selector.remove_proxy(self.proxy_list[0])) self.assertIsNone(selector._proxy) self.assertEqual(selector._proxy_list, ["8.8.8.8:2"]) selector._proxy = self.user_proxy self.assertTrue(selector.remove_proxy(self.proxy_list[0])) self.assertEqual(selector._proxy, self.user_proxy) self.assertEqual(selector._proxy_list, []) self.assertFalse(selector.remove_proxy(self.user_proxy)) self.assertEqual(selector._proxy, self.user_proxy) self.assertEqual(selector._proxy_list, [])
def test_get_with_multiple_proxies_overwrite(self): selector = ProxySelector() selector._proxy = self.user_proxy selector._proxy_list = self.proxy_list for _ in range(self.list_length * 2): self.assertEqual(selector.get_proxy(), self.user_proxy)
def test_remove_with_multiple_proxies_overwrite(self): selector = ProxySelector() selector._proxy = self.user_proxy selector._proxy_list = self.proxy_list self.assertTrue(selector.remove_proxy(self.proxy_list[0])) self.assertEqual(selector._proxy, self.user_proxy) self.assertEqual(selector._proxy_list, ["8.8.8.8:2"]) self.assertTrue(selector.remove_proxy(self.user_proxy)) self.assertIsNone(selector._proxy) self.assertEqual(selector._proxy_list, ["8.8.8.8:2"]) self.assertTrue(selector.remove_proxy(self.proxy_list[0])) self.assertIsNone(selector._proxy) self.assertEqual(selector._proxy_list, [])
def test_get_with_single_proxy(self): selector = ProxySelector() selector._proxy = self.user_proxy self.assertEqual(selector.get_proxy(), self.user_proxy)
def test_remove_with_single_proxy_fallback_prevention(self): selector = ProxySelector(prevent_fallback=True) selector._proxy = self.user_proxy self.assertFalse(selector.remove_proxy(self.user_proxy)) self.assertEqual(selector._proxy, self.user_proxy)
def test_remove_with_single_proxy(self): selector = ProxySelector() selector._proxy = self.user_proxy self.assertTrue(selector.remove_proxy(self.user_proxy)) self.assertIsNone(selector._proxy)