Initial import to Tizen
[profile/ivi/python-twisted.git] / twisted / trial / test / test_testcase.py
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 Direct unit tests for L{twisted.trial.unittest.TestCase}.
6 """
7
8 from twisted.trial.unittest import TestCase
9
10
11 class TestCaseTests(TestCase):
12     """
13     L{TestCase} tests.
14     """
15     class MyTestCase(TestCase):
16         """
17         Some test methods which can be used to test behaviors of
18         L{TestCase}.
19         """
20         def test_1(self):
21             pass
22
23     def setUp(self):
24         """
25         Create a couple instances of C{MyTestCase}, each for the same test
26         method, to be used in the test methods of this class.
27         """
28         self.first = self.MyTestCase('test_1')
29         self.second = self.MyTestCase('test_1')
30
31
32     def test_equality(self):
33         """
34         In order for one test method to be runnable twice, two TestCase
35         instances with the same test method name must not compare as equal.
36         """
37         self.assertTrue(self.first == self.first)
38         self.assertTrue(self.first != self.second)
39         self.assertFalse(self.first == self.second)
40         
41
42     def test_hashability(self):
43         """
44         In order for one test method to be runnable twice, two TestCase
45         instances with the same test method name should not have the same
46         hash value.
47         """
48         container = {}
49         container[self.first] = None
50         container[self.second] = None
51         self.assertEqual(len(container), 2)