From 995be4a1375340a53668dd80444756d77302000d Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 19 Dec 2014 14:11:17 -0500 Subject: [PATCH] Fixed refs #24007 test on Windows. --- tests/model_regress/test_pickle.py | 12 +++++++++--- 1 file 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")