[Checkins] SVN: zc.buildout/trunk/src/zc/buildout/testing. Added an uncd function to undo previous cd calls.
Jim Fulton
jim at zope.com
Wed Sep 28 14:34:15 EST 2011
Log message for revision 122988:
Added an uncd function to undo previous cd calls.
Changed a spawn call to a subprocess call to avoid some spurious output.
Changed:
U zc.buildout/trunk/src/zc/buildout/testing.py
U zc.buildout/trunk/src/zc/buildout/testing.txt
-=-
Modified: zc.buildout/trunk/src/zc/buildout/testing.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/testing.py 2011-09-28 18:57:38 UTC (rev 122987)
+++ zc.buildout/trunk/src/zc/buildout/testing.py 2011-09-28 19:34:14 UTC (rev 122988)
@@ -147,14 +147,18 @@
if executable == sys.executable:
env['PYTHONPATH'] = setuptools_location
# else pass an executable that has setuptools! See testselectingpython.py.
- args.append(env)
here = os.getcwd()
try:
os.chdir(d)
- os.spawnle(os.P_WAIT, executable,
- zc.buildout.easy_install._safe_arg(executable),
- setup, *args)
+ p = subprocess.Popen(
+ [zc.buildout.easy_install._safe_arg(executable), setup] + args,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ close_fds=True, env=env)
+ out = p.stdout.read()
+ if p.wait():
+ print out
+
if os.path.exists('build'):
rmtree('build')
finally:
@@ -399,6 +403,15 @@
return (
os.path.join(buildout, 'bin', 'py'), site_packages_dir)
+ cdpaths = []
+ def cd(*path):
+ path = os.path.join(*path)
+ cdpaths.append(os.path.abspath(os.getcwd()))
+ os.chdir(path)
+
+ def uncd():
+ os.chdir(cdpaths.pop())
+
test.globs.update(dict(
sample_buildout = sample,
ls = ls,
@@ -411,7 +424,7 @@
system = system,
call_py = call_py,
get = get,
- cd = (lambda *path: os.chdir(os.path.join(*path))),
+ cd = cd, uncd = uncd,
join = os.path.join,
sdist = sdist,
bdist_egg = bdist_egg,
Modified: zc.buildout/trunk/src/zc/buildout/testing.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/testing.txt 2011-09-28 18:57:38 UTC (rev 122987)
+++ zc.buildout/trunk/src/zc/buildout/testing.txt 2011-09-28 19:34:14 UTC (rev 122988)
@@ -79,6 +79,11 @@
The directory will be reset at the end of the test.
+``uncd()``
+ Change to the directory that was current prior to the previous
+ call to ``cd``. You can call ``cd`` multiple times and then
+ ``uncd`` the same number of times to return to the same location.
+
``join(*path)``
A convenient reference to os.path.join.
More information about the checkins
mailing list