]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/unittest/test/support.py
4 class TestHashing(object):
5 """Used as a mixin for TestCase"""
7 # Check for a valid __hash__ implementation
9 for obj_1
, obj_2
in self
.eq_pairs
:
11 if not hash(obj_1
) == hash(obj_2
):
12 self
.fail("%r and %r do not hash equal" % (obj_1
, obj_2
))
13 except KeyboardInterrupt:
16 self
.fail("Problem hashing %r and %r: %s" % (obj_1
, obj_2
, e
))
18 for obj_1
, obj_2
in self
.ne_pairs
:
20 if hash(obj_1
) == hash(obj_2
):
21 self
.fail("%s and %s hash equal, but shouldn't" %
23 except KeyboardInterrupt:
26 self
.fail("Problem hashing %s and %s: %s" % (obj_1
, obj_2
, e
))
29 class TestEquality(object):
30 """Used as a mixin for TestCase"""
32 # Check for a valid __eq__ implementation
34 for obj_1
, obj_2
in self
.eq_pairs
:
35 self
.assertEqual(obj_1
, obj_2
)
36 self
.assertEqual(obj_2
, obj_1
)
38 # Check for a valid __ne__ implementation
40 for obj_1
, obj_2
in self
.ne_pairs
:
41 self
.assertNotEqual(obj_1
, obj_2
)
42 self
.assertNotEqual(obj_2
, obj_1
)
45 class LoggingResult(unittest
.TestResult
):
46 def __init__(self
, log
):
48 super(LoggingResult
, self
).__init
__()
50 def startTest(self
, test
):
51 self
._events
.append('startTest')
52 super(LoggingResult
, self
).startTest(test
)
54 def startTestRun(self
):
55 self
._events
.append('startTestRun')
56 super(LoggingResult
, self
).startTestRun()
58 def stopTest(self
, test
):
59 self
._events
.append('stopTest')
60 super(LoggingResult
, self
).stopTest(test
)
62 def stopTestRun(self
):
63 self
._events
.append('stopTestRun')
64 super(LoggingResult
, self
).stopTestRun()
66 def addFailure(self
, *args
):
67 self
._events
.append('addFailure')
68 super(LoggingResult
, self
).addFailure(*args
)
70 def addSuccess(self
, *args
):
71 self
._events
.append('addSuccess')
72 super(LoggingResult
, self
).addSuccess(*args
)
74 def addError(self
, *args
):
75 self
._events
.append('addError')
76 super(LoggingResult
, self
).addError(*args
)
78 def addSkip(self
, *args
):
79 self
._events
.append('addSkip')
80 super(LoggingResult
, self
).addSkip(*args
)
82 def addExpectedFailure(self
, *args
):
83 self
._events
.append('addExpectedFailure')
84 super(LoggingResult
, self
).addExpectedFailure(*args
)
86 def addUnexpectedSuccess(self
, *args
):
87 self
._events
.append('addUnexpectedSuccess')
88 super(LoggingResult
, self
).addUnexpectedSuccess(*args
)
91 class ResultWithNoStartTestRunStopTestRun(object):
92 """An object honouring TestResult before startTestRun/stopTestRun."""
99 self
.expectedFailures
= []
100 self
.unexpectedSuccesses
= []
101 self
.shouldStop
= False
103 def startTest(self
, test
):
106 def stopTest(self
, test
):
109 def addError(self
, test
):
112 def addFailure(self
, test
):
115 def addSuccess(self
, test
):
118 def wasSuccessful(self
):