-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
57 lines (42 loc) · 1.47 KB
/
tests.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
import unittest
import sys
import nose
from nose.core import TextTestRunner
from nose.result import TextTestResult
from cStringIO import StringIO
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):
print >> sys.stderr, "%r ... error\n\t%r" % (test, err)
def addFailure(self, test, err):
print >> sys.stderr, "%r ... failure\n\t%r" % (test, err)
def addSuccess(self, test):
print >> sys.stdout, "%r ... ok" % test
class MyTextTestRunner(TextTestRunner):
def __init__(self):
TextTestRunner.__init__(self, stream=StringIO())
def _makeResult(self):
return MyTextTestResult(self.stream,
self.descriptions,
self.verbosity,
self.config)
nose.main(testRunner=MyTextTestRunner())