summaryrefslogtreecommitdiff
path: root/pbr/tests/base.py
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2014-05-29 08:55:19 +1200
committerRobert Collins <rbtcollins@hp.com>2014-05-29 08:56:32 +1200
commit6f4ff3c05a705bdba516f64d0517b55248e6596d (patch)
treefcc23ed8040e25c43111c2e30e91c87d5258055f /pbr/tests/base.py
parent2e2245c78301ec390601e5bd3b347a3703077be8 (diff)
downloadpbr-6f4ff3c05a705bdba516f64d0517b55248e6596d.tar.gz
Allow _run_cmd to run commands in any directory.
This is needed to avoid running pip install within the directory of the test package on Python2.6, where it helpfully (not really) installs the test package, not pbr. Change-Id: I956ad29f68a32cb4d33af448333f649043e0a655
Diffstat (limited to 'pbr/tests/base.py')
-rw-r--r--pbr/tests/base.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pbr/tests/base.py b/pbr/tests/base.py
index c58414e..ce20de1 100644
--- a/pbr/tests/base.py
+++ b/pbr/tests/base.py
@@ -119,14 +119,18 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
def run_setup(self, *args, **kwargs):
return self._run_cmd(sys.executable, ('setup.py',) + args, **kwargs)
- def _run_cmd(self, cmd, args=[], allow_fail=True):
+ def _run_cmd(self, cmd, args=[], allow_fail=True, cwd=None):
"""Run a command in the root of the test working copy.
Runs a command, with the given argument list, in the root of the test
working copy--returns the stdout and stderr streams and the exit code
from the subprocess.
+
+ :param cwd: If falsy run within the test package dir, otherwise run
+ within the named path.
"""
- result = _run_cmd([cmd] + list(args), cwd=self.package_dir)
+ cwd = cwd or self.package_dir
+ result = _run_cmd([cmd] + list(args), cwd=cwd)
if result[2] and not allow_fail:
raise Exception("Command failed retcode=%s" % result[2])
return result