-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode-review-1.py
69 lines (53 loc) · 2.06 KB
/
code-review-1.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
import unittest
import sys
import nose
from nose.core import TextTestRunner
from nose.result import TextTestResult
from cStringIO import StringIO
from unittest.runner import _WritelnDecorator
class Tests(unittest.TestCase):
def test_1(self):
"""Test 1"""
# print 'something'
self.assertEquals(1, 1)
def test_2(self):
"""Test 2"""
self.assertEquals(1, 1)
def test_3(self):
"""Test 3"""
self.assertEquals(1, 1)
def test_4(self):
"""Test 4"""
self.assertEquals(1, 1)
def test_5(self):
"""Test 5"""
# print 'something'
raise AssertionError("error")
self.assertEquals(1, 1)
if __name__ == '__main__':
class MyTextTestResult(TextTestResult):
def addError(self, test, err):
current_stream = self.stream
self.stream = _WritelnDecorator(sys.stderr)
TextTestResult.addError(self, test, err)
self.stream = current_stream
def addFailure(self, test, err):
current_stream = self.stream
self.stream = _WritelnDecorator(sys.stderr)
TextTestResult.addFailure(self, test, err)
self.stream = current_stream
def printErrors(self):
current_stream = self.stream
self.stream = _WritelnDecorator(sys.stderr)
TextTestResult.printErrors(self)
self.stream = current_stream
class MyTextTestRunner(TextTestRunner):
def __init__(self):
TextTestRunner.__init__(self, stream=_WritelnDecorator(sys.stdout), verbosity=2)
def _makeResult(self):
return MyTextTestResult(self.stream,
self.descriptions,
self.verbosity,
self.config)
nose.run(testRunner=MyTextTestRunner(), argv=['nosetests', __file__, '-s', '-v'])
# nose.run(argv=['nosetests', __file__, '-s', '-v', '--with-xunit', '--with-id'])