Use a subdirectory in the TEMP directory to speed up tmpdir creation
Fix #105
This commit is contained in:
		
							parent
							
								
									aa25fb05a9
								
							
						
					
					
						commit
						330de0a93d
					
				|  | @ -12,6 +12,12 @@ | ||||||
|   fixtures declared on the first one. |   fixtures declared on the first one. | ||||||
|   Thanks Florian Bruhin for reporting and Bruno Oliveira for the PR. |   Thanks Florian Bruhin for reporting and Bruno Oliveira for the PR. | ||||||
| 
 | 
 | ||||||
|  | - optimized tmpdir fixture initialization, which should make test sessions | ||||||
|  |   faster (specially when using pytest-xdist). The only visible effect | ||||||
|  |   is that now pytest uses a subdirectory in the $TEMP directory for all | ||||||
|  |   directories created by this fixture (defaults to $TEMP/pytest-$USER). | ||||||
|  |   Thanks Bruno Oliveira for the PR. | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 2.7.2 (compared to 2.7.1) | 2.7.2 (compared to 2.7.1) | ||||||
| ----------------------------- | ----------------------------- | ||||||
|  |  | ||||||
|  | @ -43,7 +43,14 @@ class TempdirHandler: | ||||||
|                     basetemp.remove() |                     basetemp.remove() | ||||||
|                 basetemp.mkdir() |                 basetemp.mkdir() | ||||||
|             else: |             else: | ||||||
|                 basetemp = py.path.local.make_numbered_dir(prefix='pytest-') |                 # use a sub-directory in the temproot to speed-up | ||||||
|  |                 # make_numbered_dir() call | ||||||
|  |                 import getpass | ||||||
|  |                 temproot = py.path.local.get_temproot() | ||||||
|  |                 rootdir = temproot.join('pytest-%s' % getpass.getuser()) | ||||||
|  |                 rootdir.ensure(dir=1) | ||||||
|  |                 basetemp = py.path.local.make_numbered_dir(prefix='pytest-', | ||||||
|  |                                                            rootdir=rootdir) | ||||||
|             self._basetemp = t = basetemp.realpath() |             self._basetemp = t = basetemp.realpath() | ||||||
|             self.trace("new basetemp", t) |             self.trace("new basetemp", t) | ||||||
|             return t |             return t | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue