mirror of
				https://github.com/django/django.git
				synced 2025-11-04 05:35:37 +00:00 
			
		
		
		
	Fixed refs #24007 test on Windows.
This commit is contained in:
		
							parent
							
								
									1d9fc5caa9
								
							
						
					
					
						commit
						995be4a137
					
				
					 1 changed files with 9 additions and 3 deletions
				
			
		| 
						 | 
					@ -1,11 +1,12 @@
 | 
				
			||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
import pickle
 | 
					import pickle
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import tempfile
 | 
					 | 
				
			||||||
import warnings
 | 
					import warnings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django.db import models, DJANGO_VERSION_PICKLE_KEY
 | 
					from django.db import models, DJANGO_VERSION_PICKLE_KEY
 | 
				
			||||||
 | 
					from django.core.files.temp import NamedTemporaryFile
 | 
				
			||||||
from django.test import TestCase
 | 
					from django.test import TestCase
 | 
				
			||||||
from django.utils.encoding import force_text
 | 
					from django.utils.encoding import force_text
 | 
				
			||||||
from django.utils.version import get_major_version, get_version
 | 
					from django.utils.version import get_major_version, get_version
 | 
				
			||||||
| 
						 | 
					@ -79,13 +80,18 @@ print(article.headline)"""
 | 
				
			||||||
            article_text="This is an article",
 | 
					            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.write(script_template % pickle.dumps(a))
 | 
				
			||||||
            script.flush()
 | 
					            script.flush()
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                result = subprocess.check_output(
 | 
					                result = subprocess.check_output(
 | 
				
			||||||
                    [sys.executable, script.name],
 | 
					                    [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:
 | 
					            except subprocess.CalledProcessError:
 | 
				
			||||||
                self.fail("Unable to reload model pickled data")
 | 
					                self.fail("Unable to reload model pickled data")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue