Initial import to Tizen
[profile/ivi/python-twisted.git] / twisted / internet / test / test_abstract.py
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 Tests for L{twisted.internet.abstract}, a collection of APIs for implementing
6 reactors.
7 """
8
9 from twisted.trial.unittest import TestCase
10
11 from twisted.internet.abstract import isIPv6Address
12
13 class IPv6AddressTests(TestCase):
14     """
15     Tests for L{isIPv6Address}, a function for determining if a particular
16     string is an IPv6 address literal.
17     """
18     def test_empty(self):
19         """
20         The empty string is not an IPv6 address literal.
21         """
22         self.assertFalse(isIPv6Address(""))
23
24
25     def test_colon(self):
26         """
27         A single C{":"} is not an IPv6 address literal.
28         """
29         self.assertFalse(isIPv6Address(":"))
30
31
32     def test_loopback(self):
33         """
34         C{"::1"} is the IPv6 loopback address literal.
35         """
36         self.assertTrue(isIPv6Address("::1"))
37
38
39     def test_scopeID(self):
40         """
41         An otherwise valid IPv6 address literal may also include a C{"%"}
42         followed by an arbitrary scope identifier.
43         """
44         self.assertTrue(isIPv6Address("fe80::1%eth0"))
45         self.assertTrue(isIPv6Address("fe80::2%1"))
46         self.assertTrue(isIPv6Address("fe80::3%en2"))
47
48
49     def test_invalidWithScopeID(self):
50         """
51         An otherwise invalid IPv6 address literal is still invalid with a
52         trailing scope identifier.
53         """
54         self.assertFalse(isIPv6Address("%eth0"))
55         self.assertFalse(isIPv6Address(":%eth0"))
56         self.assertFalse(isIPv6Address("hello%eth0"))