Skip to content
Newer
Older
100644 45 lines (33 sloc) 980 Bytes
e9c339a @3kwa foundation for testing
authored
1 import unittest
2 import socket
3
4 try:
5 import redis
6
7 host, port = '127.0.0.1', 6379
8 for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC,
9 socket.SOCK_STREAM):
10 af, socktype, proto, canonname, sa = res
11 s = None
12 try:
13 s = socket.socket(af, socktype, proto)
14 s.settimeout(1.0)
15 s.connect((host, port))
16 s.close()
17 except socket.error:
18 if s:
19 s.close()
20 raise
21 break
22
23 except ImportError:
24
25 class RedisSessionTest(unittest.TestCase):
26 def test_nothing(self):
27 self.fail("redis-py not available")
28
29 except socket.error:
30
31 class RedisSessionTest(unittest.TestCase):
32 def test_nothing(self):
33 self.fail("redis not reachable")
34
35
36 else:
37
38 class RedisSessionTest(unittest.TestCase):
39
40 def test_something(self):
41 self.assertTrue(True)
42
43 if __name__ == '__main__':
44 unittest.main()
Something went wrong with that request. Please try again.