10
10
except ImportError :
11
11
from mock import patch
12
12
13
- fileDir = os .path .dirname (os .path .realpath (' __file__' ))
13
+ fileDir = os .path .dirname (os .path .realpath (__file__ ))
14
14
testargs = ["" , os .path .join (fileDir , 'java/cc/SwitchCaseStatement.java' )]
15
15
with patch .object (sys , 'argv' , testargs ):
16
16
from calc import branches , compound
@@ -25,7 +25,7 @@ def names(ast):
25
25
comment = next (ast .filter (javalang .tree .Documented ))[1 ]
26
26
return int (re .search (r'[\d]+' , comment .documentation ).group (0 ))
27
27
28
- for java in glob ('java/names/*.java' ):
28
+ for java in glob (os . path . join ( fileDir , 'java/names/*.java' ) ):
29
29
with open (java , encoding = 'utf-8' ) as f :
30
30
try :
31
31
ast = javalang .parse .parse (f .read ())
@@ -36,11 +36,11 @@ def names(ast):
36
36
receivedNames += compound (node )
37
37
38
38
if (receivedNames != expectedNames ):
39
- raise Exception ('\n Test failed. Expected ' + str (expectedNames ) + ', receivedNames ' + str (receivedNames ))
39
+ raise Exception ('\n Test failed. Expected ' + str (expectedNames ) + ', received ' + str (receivedNames ))
40
40
except Exception as e :
41
41
sys .exit (str (e ) + ': ' + java )
42
42
43
- for java in glob ('java/cc/*.java' ):
43
+ for java in glob (os . path . join ( fileDir , 'java/cc/*.java' ) ):
44
44
with open (java , encoding = 'utf-8' ) as f :
45
45
try :
46
46
ast = javalang .parse .parse (f .read ())
@@ -51,11 +51,11 @@ def names(ast):
51
51
receivedCC += branches (node )
52
52
53
53
if (receivedCC != expectedCC ):
54
- raise Exception ('\n Test failed. Expected ' + str (expectedCC ) + ', receivedCC ' + str (receivedCC ))
54
+ raise Exception ('\n Test failed. Expected ' + str (expectedCC ) + ', received ' + str (receivedCC ))
55
55
56
56
print ('.' , end = '' , flush = True ),
57
57
except Exception as e :
58
58
sys .exit (str (e ) + ': ' + java )
59
59
60
- print (' OK ' )
60
+ print ('\n OK ' )
61
61
0 commit comments