Loading tests/model_regress/tests.py +12 −3 Original line number Diff line number Diff line Loading @@ -2,13 +2,14 @@ from __future__ import unicode_literals import datetime from operator import attrgetter import os import pickle import subprocess import sys import tempfile import unittest from django.core.exceptions import ValidationError from django.core.files.temp import NamedTemporaryFile from django.test import TestCase, skipUnlessDBFeature from django.utils import six from django.utils.timezone import get_fixed_timezone Loading Loading @@ -272,11 +273,19 @@ 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(['python', script.name]) result = subprocess.check_output( [sys.executable, script.name], 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") self.assertEqual(result.strip().decode(), "Some object") Loading
tests/model_regress/tests.py +12 −3 Original line number Diff line number Diff line Loading @@ -2,13 +2,14 @@ from __future__ import unicode_literals import datetime from operator import attrgetter import os import pickle import subprocess import sys import tempfile import unittest from django.core.exceptions import ValidationError from django.core.files.temp import NamedTemporaryFile from django.test import TestCase, skipUnlessDBFeature from django.utils import six from django.utils.timezone import get_fixed_timezone Loading Loading @@ -272,11 +273,19 @@ 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(['python', script.name]) result = subprocess.check_output( [sys.executable, script.name], 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") self.assertEqual(result.strip().decode(), "Some object")