-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_proxy.py
35 lines (27 loc) · 886 Bytes
/
test_proxy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
''' Unit testing rotatingproxy '''
import unittest
from rotatingproxy import RotatingProxy
class ProxyTestCase(unittest.TestCase):
''' Tests if proxy is set '''
def setUp(self):
''' set up RotatingProxy object '''
self.rp = RotatingProxy()
def test_is_random_proxy(self):
''' Is Random Proxy? '''
try:
self.rp.set_proxy(self, "r")
passed = True
except Exception as e:
passed = False
self.assertTrue(passed)
def test_is_index_proxy(self):
''' Is Proxy in list of indexes? '''
try:
for p in range(3):
self.rp.set_proxy(self, proxy_num=p)
passed = True
except Exception as e:
passed = False
self.assertTrue(passed)
if __name__ == '__main__':
unittest.main()