ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/test/py_tests/unit_tools/support.py
(Generate patch)

Comparing ray/test/py_tests/unit_tools/support.py (file contents):
Revision 1.1 by schorsch, Sun Dec 7 20:40:51 2003 UTC vs.
Revision 1.3 by schorsch, Thu Mar 10 01:49:56 2016 UTC

# Line 1 | Line 1
1 + from __future__ import print_function
2  
3   import os
4 < import string
4 > import sys
5  
6   import unittest
7  
8   def _find_raydir():
9 <        try: thisfile = __file__
10 <        except NameError:
11 <                import support
12 <                thisfile = support.__file__
13 <        sdirn = string.count(thisfile, os.sep)
14 <        if sdirn in [0, 1]:
15 <                raydir = os.path.join('..','..')
15 <        elif sdirn == 2:
16 <                raydir = os.path.join('..')
17 <        elif sdirn == 3:
18 <                raydir = '.'
19 <        else:
20 <                unit_tools = os.path.split(thisfile)[0]
21 <                py_tests = os.path.split(unit_tools)[0]
22 <                test = os.path.split(py_tests)[0]
23 <                raydir = os.path.split(test)[0]
9 >        if __name__ == '__main__':
10 >                thisfile = sys.argv[0]
11 >        else: thisfile = sys.modules[__name__].__file__
12 >        unit_tools = os.path.abspath(os.path.dirname(thisfile))
13 >        py_tests = os.path.dirname(unit_tools)
14 >        test = os.path.dirname(py_tests)
15 >        raydir = os.path.dirname(test)
16          return raydir
17  
18   RAYDIR = _find_raydir()
# Line 28 | Line 20 | DATADIR = os.path.join(RAYDIR, 'test', 'test data')
20   BINDIR = os.path.join(RAYDIR, 'bin')
21  
22   def binfile(fn):
23 <        '''return the full/relative path to file in bin dir'''
23 >        '''return the full path to file in bin dir'''
24          if os.name == 'nt':
25                  return os.path.normpath(os.path.join(BINDIR, fn + '.exe'))
26          else: return os.path.normpath(os.path.join(BINDIR, fn))
27  
28   def datafile(fn):
29 <        '''return the full/relative path to file in data dir'''
29 >        '''return the full path to file in data dir'''
30          return os.path.normpath(os.path.join(DATADIR, fn))
31  
32   def run_case(c):
# Line 42 | Line 34 | def run_case(c):
34          s = unittest.makeSuite(c, 'test')
35          s.run(res)
36          if res.errors or res.failures:
37 <                print ' failed'
38 <                print '-----------------------------'
37 >                print(' failed')
38 >                print('-----------------------------')
39                  for e in res.errors:
40 <                        print e[1]
40 >                        print(e[1])
41                  for e in res.failures:
42 <                        es = string.strip(e[1])
43 <                        sl = string.split(es, '\n')
44 <                        print sl[-1]
45 <                print '-----------------------------'
42 >                        es = e[1].strip()
43 >                        sl = '\n'.split(es)
44 >                        print(sl[-1])
45 >                print('-----------------------------')
46          else:
47 <                print ' ok'
47 >                print(' ok')
48                  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)