Show More
|
1 | NO CONTENT: file renamed from IPython/testing/ipdoctest.py to IPython/testing/attic/ipdoctest.py |
|
1 | NO CONTENT: file renamed from IPython/testing/parametric.py to IPython/testing/attic/parametric.py |
|
1 | NO CONTENT: file renamed from IPython/testing/tcommon.py to IPython/testing/attic/tcommon.py |
|
1 | NO CONTENT: file renamed from IPython/testing/testTEMPLATE.py to IPython/testing/attic/testTEMPLATE.py |
|
1 | NO CONTENT: file renamed from IPython/testing/tstTEMPLATE_doctest.py to IPython/testing/attic/tstTEMPLATE_doctest.py |
|
1 | NO CONTENT: file renamed from IPython/testing/tstTEMPLATE_doctest.txt to IPython/testing/attic/tstTEMPLATE_doctest.txt |
@@ -1,72 +1,86 b'' | |||
|
1 | """Utilities for testing code. | |
|
1 | """DEPRECATED - use IPython.testing.util instead. | |
|
2 | ||
|
3 | Utilities for testing code. | |
|
2 | 4 | """ |
|
3 | 5 | |
|
6 | ############################################################################# | |
|
7 | ||
|
8 | # This was old testing code we never really used in IPython. The pieces of | |
|
9 | # testing machinery from snakeoil that were good have already been merged into | |
|
10 | # the nose plugin, so this can be taken away soon. Leave a warning for now, | |
|
11 | # we'll remove it in a later release (around 0.10 or so). | |
|
12 | from warnings import warn | |
|
13 | warn('This will be removed soon. Use IPython.testing.util instead', | |
|
14 | DeprecationWarning) | |
|
15 | ||
|
16 | ############################################################################# | |
|
17 | ||
|
4 | 18 | # Required modules and packages |
|
5 | 19 | |
|
6 | 20 | # Standard Python lib |
|
7 | 21 | import os |
|
8 | 22 | import sys |
|
9 | 23 | |
|
10 | 24 | # From this project |
|
11 | 25 | from IPython.tools import utils |
|
12 | 26 | |
|
13 | 27 | # path to our own installation, so we can find source files under this. |
|
14 | 28 | TEST_PATH = os.path.dirname(os.path.abspath(__file__)) |
|
15 | 29 | |
|
16 | 30 | # Global flag, used by vprint |
|
17 | 31 | VERBOSE = '-v' in sys.argv or '--verbose' in sys.argv |
|
18 | 32 | |
|
19 | 33 | ########################################################################## |
|
20 | 34 | # Code begins |
|
21 | 35 | |
|
22 | 36 | # Some utility functions |
|
23 | 37 | def vprint(*args): |
|
24 | 38 | """Print-like function which relies on a global VERBOSE flag.""" |
|
25 | 39 | if not VERBOSE: |
|
26 | 40 | return |
|
27 | 41 | |
|
28 | 42 | write = sys.stdout.write |
|
29 | 43 | for item in args: |
|
30 | 44 | write(str(item)) |
|
31 | 45 | write('\n') |
|
32 | 46 | sys.stdout.flush() |
|
33 | 47 | |
|
34 | 48 | def test_path(path): |
|
35 | 49 | """Return a path as a subdir of the test package. |
|
36 | 50 | |
|
37 | 51 | This finds the correct path of the test package on disk, and prepends it |
|
38 | 52 | to the input path.""" |
|
39 | ||
|
53 | ||
|
40 | 54 | return os.path.join(TEST_PATH,path) |
|
41 | 55 | |
|
42 | 56 | def fullPath(startPath,files): |
|
43 | 57 | """Make full paths for all the listed files, based on startPath. |
|
44 | 58 | |
|
45 | 59 | Only the base part of startPath is kept, since this routine is typically |
|
46 | 60 | used with a script's __file__ variable as startPath. The base of startPath |
|
47 | 61 | is then prepended to all the listed files, forming the output list. |
|
48 | 62 | |
|
49 | 63 | :Parameters: |
|
50 | 64 | startPath : string |
|
51 | 65 | Initial path to use as the base for the results. This path is split |
|
52 | 66 | using os.path.split() and only its first component is kept. |
|
53 | 67 | |
|
54 | 68 | files : string or list |
|
55 | 69 | One or more files. |
|
56 | 70 | |
|
57 | 71 | :Examples: |
|
58 | ||
|
72 | ||
|
59 | 73 | >>> fullPath('/foo/bar.py',['a.txt','b.txt']) |
|
60 | 74 | ['/foo/a.txt', '/foo/b.txt'] |
|
61 | 75 | |
|
62 | 76 | >>> fullPath('/foo',['a.txt','b.txt']) |
|
63 | 77 | ['/a.txt', '/b.txt'] |
|
64 | 78 | |
|
65 | 79 | If a single file is given, the output is still a list: |
|
66 | 80 | >>> fullPath('/foo','a.txt') |
|
67 | 81 | ['/a.txt'] |
|
68 | 82 | """ |
|
69 | ||
|
83 | ||
|
70 | 84 | files = utils.list_strings(files) |
|
71 | 85 | base = os.path.split(startPath)[0] |
|
72 | 86 | return [ os.path.join(base,f) for f in files ] |
General Comments 0
You need to be logged in to leave comments.
Login now