diff options
| author | Tim Graham <timograham@gmail.com> | 2014-12-19 14:11:17 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-12-19 14:11:17 -0500 |
| commit | 995be4a1375340a53668dd80444756d77302000d (patch) | |
| tree | a1bedf00706d4e8331b1e6090bba27ab965e7581 | |
| parent | 1d9fc5caa947ff4ee72180185e91a9a145171712 (diff) | |
Fixed refs #24007 test on Windows.
| -rw-r--r-- | tests/model_regress/test_pickle.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/model_regress/test_pickle.py b/tests/model_regress/test_pickle.py index 5f97a72606..b0e3fa9d66 100644 --- a/tests/model_regress/test_pickle.py +++ b/tests/model_regress/test_pickle.py @@ -1,11 +1,12 @@ import datetime +import os import pickle import subprocess import sys -import tempfile import warnings from django.db import models, DJANGO_VERSION_PICKLE_KEY +from django.core.files.temp import NamedTemporaryFile from django.test import TestCase from django.utils.encoding import force_text from django.utils.version import get_major_version, get_version @@ -79,13 +80,18 @@ print(article.headline)""" article_text="This is an article", ) - with tempfile.NamedTemporaryFile(mode='w+', suffix=".py", dir='.', delete=True) as script: + with NamedTemporaryFile(mode='w+', suffix=".py", dir='.') as script: script.write(script_template % pickle.dumps(a)) script.flush() try: result = subprocess.check_output( [sys.executable, script.name], - env={'PYTHONPATH': ':'.join(sys.path)} + env={ + # Needed to run test outside of tests directory + str('PYTHONPATH'): os.pathsep.join(sys.path), + # Needed on Windows because http://bugs.python.org/issue8557 + str('PATH'): os.environ['PATH'], + } ) except subprocess.CalledProcessError: self.fail("Unable to reload model pickled data") |
