##// END OF EJS Templates
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ipython branch. This is not a true merge in the formal sense because all history is not coming over with the files. For a detailed history of the added files, please see the ipython1-dev branch or the svn repository on scipy.org that ipython1-dev came from. More specifically, here is what I have done in this commit: 1) Moved the following by hand ipython1.config -> IPython.config ipython1.kernel -> IPython.kernel ipython1.external -> IPython.external ipython1.core -> IPython.kernel.core ipython1.testutils -> IPython.testing ipython1.tools -> IPython.tools 2) Moved IPython.tools.guid -> IPython1.external.guid 3) Renamed: ipython1 -> IPython IPython.core -> IPython.kernel.core IPython.testutils -> IPython.testing 4) Then did a "bzr add" for all the new stuff. That is all folks!

File last commit:

r1234:52b55407
r1234:52b55407
Show More
tutils.py
72 lines | 1.9 KiB | text/x-python | PythonLexer
"""Utilities for testing code.
"""
# Required modules and packages
# Standard Python lib
import os
import sys
# From this project
from IPython.tools import utils
# path to our own installation, so we can find source files under this.
TEST_PATH = os.path.dirname(os.path.abspath(__file__))
# Global flag, used by vprint
VERBOSE = '-v' in sys.argv or '--verbose' in sys.argv
##########################################################################
# Code begins
# Some utility functions
def vprint(*args):
"""Print-like function which relies on a global VERBOSE flag."""
if not VERBOSE:
return
write = sys.stdout.write
for item in args:
write(str(item))
write('\n')
sys.stdout.flush()
def test_path(path):
"""Return a path as a subdir of the test package.
This finds the correct path of the test package on disk, and prepends it
to the input path."""
return os.path.join(TEST_PATH,path)
def fullPath(startPath,files):
"""Make full paths for all the listed files, based on startPath.
Only the base part of startPath is kept, since this routine is typically
used with a script's __file__ variable as startPath. The base of startPath
is then prepended to all the listed files, forming the output list.
:Parameters:
startPath : string
Initial path to use as the base for the results. This path is split
using os.path.split() and only its first component is kept.
files : string or list
One or more files.
:Examples:
>>> fullPath('/foo/bar.py',['a.txt','b.txt'])
['/foo/a.txt', '/foo/b.txt']
>>> fullPath('/foo',['a.txt','b.txt'])
['/a.txt', '/b.txt']
If a single file is given, the output is still a list:
>>> fullPath('/foo','a.txt')
['/a.txt']
"""
files = utils.list_strings(files)
base = os.path.split(startPath)[0]
return [ os.path.join(base,f) for f in files ]