1010except ImportError :
1111 from mock import patch
1212
13- fileDir = os .path .dirname (os .path .realpath (' __file__' ))
13+ fileDir = os .path .dirname (os .path .realpath (__file__ ))
1414testargs = ["" , os .path .join (fileDir , 'java/cc/SwitchCaseStatement.java' )]
1515with patch .object (sys , 'argv' , testargs ):
1616 from calc import branches , compound
@@ -25,7 +25,7 @@ def names(ast):
2525 comment = next (ast .filter (javalang .tree .Documented ))[1 ]
2626 return int (re .search (r'[\d]+' , comment .documentation ).group (0 ))
2727
28- for java in glob ('java/names/*.java' ):
28+ for java in glob (os . path . join ( fileDir , 'java/names/*.java' ) ):
2929 with open (java , encoding = 'utf-8' ) as f :
3030 try :
3131 ast = javalang .parse .parse (f .read ())
@@ -36,11 +36,11 @@ def names(ast):
3636 receivedNames += compound (node )
3737
3838 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 ))
4040 except Exception as e :
4141 sys .exit (str (e ) + ': ' + java )
4242
43- for java in glob ('java/cc/*.java' ):
43+ for java in glob (os . path . join ( fileDir , 'java/cc/*.java' ) ):
4444 with open (java , encoding = 'utf-8' ) as f :
4545 try :
4646 ast = javalang .parse .parse (f .read ())
@@ -51,11 +51,11 @@ def names(ast):
5151 receivedCC += branches (node )
5252
5353 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 ))
5555
5656 print ('.' , end = '' , flush = True ),
5757 except Exception as e :
5858 sys .exit (str (e ) + ': ' + java )
5959
60- print (' OK ' )
60+ print ('\n OK ' )
6161
0 commit comments