-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_case_test.py
70 lines (57 loc) · 2 KB
/
test_case_test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from test_case import TestCase
from test_result import TestResult
from was_run import WasRun
from broken_setup import BrokenSetup
from test_suite import TestSuite
class TestCaseTest(TestCase):
def setUp(self):
self.result= TestResult()
def testTemplateMethod(self):
test= WasRun("testMethod")
test.run(self.result)
assert("setUp testMethod tearDown " == test.log)
def testResult(self):
test= WasRun("testMethod")
test.run(self.result)
assert("1 run, 0 failed" == self.result.summary())
def testFailedResult(self):
test= WasRun("testBrokenMethod")
test.run(self.result)
assert("1 run, 1 failed" == self.result.summary())
def testFailedResultFormatting(self):
self.result.testStarted()
self.result.testFailed()
assert("1 run, 1 failed" == self.result.summary())
def setupFailed(self):
test= BrokenSetup("testMethod")
try:
test.run(self.result)
assert False
except:
pass
def testSuiteContainsFailingSetup(self):
suite= TestSuite()
suite.add(BrokenSetup("testMethod"))
suite.run(self.result)
assert("1 run, 1 failed" == self.result.summary())
def testSuite(self):
suite= TestSuite()
suite.add(WasRun("testMethod"))
suite.add(WasRun("testBrokenMethod"))
suite.run(self.result)
assert("2 run, 1 failed" == self.result.summary())
def tearDownIfFailed(self):
test= WasRun("testBrokenMethod")
test.run(self.result)
suite= TestSuite()
suite.add(TestCaseTest("testTemplateMethod"))
suite.add(TestCaseTest("testResult"))
suite.add(TestCaseTest("testFailedResultFormatting"))
suite.add(TestCaseTest("testFailedResult"))
suite.add(TestCaseTest("testSuite"))
suite.add(TestCaseTest("setupFailed"))
suite.add(TestCaseTest("testSuiteContainsFailingSetup"))
suite.add(TestCaseTest("tearDownIfFailed"))
result= TestResult()
suite.run(result)
print(result.summary())