mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	Set test.regrtest.TEMPDIR correctly when run with 'python -m test'
This commit is contained in:
		
							parent
							
								
									9efdccae25
								
							
						
					
					
						commit
						a7a0e1a0f4
					
				
					 1 changed files with 4 additions and 2 deletions
				
			
		| 
						 | 
					@ -3,7 +3,7 @@ import sys
 | 
				
			||||||
import sysconfig
 | 
					import sysconfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from test import support
 | 
					from test import support
 | 
				
			||||||
from test.regrtest import main
 | 
					from test import regrtest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# findtestdir() gets the dirname out of __file__, so we have to make it
 | 
					# findtestdir() gets the dirname out of __file__, so we have to make it
 | 
				
			||||||
# absolute before changing the working directory.
 | 
					# absolute before changing the working directory.
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ if sysconfig.is_python_build():
 | 
				
			||||||
    TEMPDIR = os.path.abspath(TEMPDIR)
 | 
					    TEMPDIR = os.path.abspath(TEMPDIR)
 | 
				
			||||||
    if not os.path.exists(TEMPDIR):
 | 
					    if not os.path.exists(TEMPDIR):
 | 
				
			||||||
        os.mkdir(TEMPDIR)
 | 
					        os.mkdir(TEMPDIR)
 | 
				
			||||||
 | 
					    regrtest.TEMPDIR = TEMPDIR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Define a writable temp dir that will be used as cwd while running
 | 
					# Define a writable temp dir that will be used as cwd while running
 | 
				
			||||||
# the tests. The name of the dir includes the pid to allow parallel
 | 
					# the tests. The name of the dir includes the pid to allow parallel
 | 
				
			||||||
| 
						 | 
					@ -29,10 +30,11 @@ if sysconfig.is_python_build():
 | 
				
			||||||
TESTCWD = 'test_python_{}'.format(os.getpid())
 | 
					TESTCWD = 'test_python_{}'.format(os.getpid())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TESTCWD = os.path.join(TEMPDIR, TESTCWD)
 | 
					TESTCWD = os.path.join(TEMPDIR, TESTCWD)
 | 
				
			||||||
 | 
					regrtest.TESTCWD = TESTCWD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Run the tests in a context manager that temporary changes the CWD to a
 | 
					# Run the tests in a context manager that temporary changes the CWD to a
 | 
				
			||||||
# temporary and writable directory. If it's not possible to create or
 | 
					# temporary and writable directory. If it's not possible to create or
 | 
				
			||||||
# change the CWD, the original CWD will be used. The original CWD is
 | 
					# change the CWD, the original CWD will be used. The original CWD is
 | 
				
			||||||
# available from support.SAVEDCWD.
 | 
					# available from support.SAVEDCWD.
 | 
				
			||||||
with support.temp_cwd(TESTCWD, quiet=True):
 | 
					with support.temp_cwd(TESTCWD, quiet=True):
 | 
				
			||||||
    main()
 | 
					    regrtest.main()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue