summaryrefslogtreecommitdiff
path: root/tests/admin_scripts
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-02-05 08:01:36 -0800
committerTim Graham <timograham@gmail.com>2019-02-05 11:01:36 -0500
commit099c36d546cda842b44a93067d45e146e4ae77e5 (patch)
treee6a33dc3e604f1e5135d2d7a9cbeccf9d0505ecf /tests/admin_scripts
parent4d425abc84cd0bae1613aa9b81a7f2fc76ed1ba3 (diff)
downloaddjango-099c36d546cda842b44a93067d45e146e4ae77e5.tar.gz
Replaced manual current directory management with subprocess's cwd argument.
Diffstat (limited to 'tests/admin_scripts')
-rw-r--r--tests/admin_scripts/tests.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 7b41c40199..79ff14ca4c 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -128,7 +128,6 @@ class AdminScriptTestCase(SimpleTestCase):
# Define a temporary environment for the subprocess
test_environ = os.environ.copy()
- old_cwd = os.getcwd()
# Set the test environment
if settings_file:
@@ -140,17 +139,12 @@ class AdminScriptTestCase(SimpleTestCase):
test_environ['PYTHONPATH'] = os.pathsep.join(python_path)
test_environ['PYTHONWARNINGS'] = ''
- # Move to the test directory and run
- os.chdir(self.test_dir)
- out, err = subprocess.Popen(
+ return subprocess.Popen(
[sys.executable, script] + args,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ cwd=self.test_dir,
env=test_environ, universal_newlines=True,
).communicate()
- # Move back to the old working directory
- os.chdir(old_cwd)
-
- return out, err
def run_django_admin(self, args, settings_file=None):
script_dir = os.path.abspath(os.path.join(os.path.dirname(django.__file__), 'bin'))