1
1
# coding: utf-8
2
2
# pylint: disable=no-self-use
3
3
import os
4
+ import subprocess
4
5
import unittest
5
6
6
- import sh
7
-
8
7
from coveralls import Coveralls
9
8
10
9
@@ -23,11 +22,17 @@ class ReporterTest(unittest.TestCase):
23
22
def setUp (self ):
24
23
os .chdir (EXAMPLE_DIR )
25
24
26
- sh .rm ('-f' , '.coverage' )
27
- sh .rm ('-f' , 'extra.py' )
25
+ try :
26
+ os .remove ('.coverage' )
27
+ except Exception :
28
+ pass
29
+ try :
30
+ os .remove ('extra.py' )
31
+ except Exception :
32
+ pass
28
33
29
34
def test_reporter (self ):
30
- sh . coverage ( ' run' , 'runtests.py' )
35
+ subprocess . call ([ 'coverage' , ' run' , 'runtests.py' ], cwd = EXAMPLE_DIR )
31
36
results = Coveralls (repo_token = 'xxx' ).get_coverage ()
32
37
assert len (results ) == 2
33
38
@@ -59,7 +64,8 @@ def test_reporter(self):
59
64
'coverage' : [None , 1 , None , 1 , 1 , 1 , 1 ]})
60
65
61
66
def test_reporter_with_branches (self ):
62
- sh .coverage ('run' , '--branch' , 'runtests.py' )
67
+ subprocess .call (['coverage' , 'run' , '--branch' , 'runtests.py' ],
68
+ cwd = EXAMPLE_DIR )
63
69
results = Coveralls (repo_token = 'xxx' ).get_coverage ()
64
70
assert len (results ) == 2
65
71
@@ -98,13 +104,19 @@ def test_reporter_with_branches(self):
98
104
'coverage' : [None , 1 , None , 1 , 1 , 1 , 1 ]})
99
105
100
106
def test_missing_file (self ):
101
- sh .echo ('print("Python rocks!")' , _out = 'extra.py' )
102
- sh .coverage ('run' , 'extra.py' )
103
- sh .rm ('-f' , 'extra.py' )
107
+ with open ('extra.py' , 'w' ) as f :
108
+ f .write ('print("Python rocks!")\n ' )
109
+ subprocess .call (['coverage' , 'run' , 'extra.py' ], cwd = EXAMPLE_DIR )
110
+ try :
111
+ os .remove ('extra.py' )
112
+ except Exception :
113
+ pass
104
114
assert Coveralls (repo_token = 'xxx' ).get_coverage () == []
105
115
106
116
def test_not_python (self ):
107
- sh .echo ('print("Python rocks!")' , _out = 'extra.py' )
108
- sh .coverage ('run' , 'extra.py' )
109
- sh .echo ("<h1>This isn't python!</h1>" , _out = 'extra.py' )
117
+ with open ('extra.py' , 'w' ) as f :
118
+ f .write ('print("Python rocks!")\n ' )
119
+ subprocess .call (['coverage' , 'run' , 'extra.py' ], cwd = EXAMPLE_DIR )
120
+ with open ('extra.py' , 'w' ) as f :
121
+ f .write ("<h1>This isn't python!</h1>\n " )
110
122
assert Coveralls (repo_token = 'xxx' ).get_coverage () == []
0 commit comments