Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

r76114 - in python/branches/py3k: Lib/importlib/test/source/util.py Misc/NEWS

 

 

Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

Nov 4, 2009, 6:20 PM

Post #1 of 1 (35 views)
Permalink
r76114 - in python/branches/py3k: Lib/importlib/test/source/util.py Misc/NEWS

Author: brett.cannon
Date: Thu Nov 5 02:26:57 2009
New Revision: 76114

Log:
Use tempfile.mkdtemp() instead of tempfile.tempdir for where importlib places
source files for tests. Allows for concurrent execution of the tests by
preventing various executions from trampling each other.

Closes issue #7248.


Modified:
python/branches/py3k/Lib/importlib/test/source/util.py
python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/importlib/test/source/util.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/source/util.py (original)
+++ python/branches/py3k/Lib/importlib/test/source/util.py Thu Nov 5 02:26:57 2009
@@ -42,8 +42,8 @@
that contains the name passed into the context manager that caused the
creation of the module.

- All files are created in a temporary directory specified by
- tempfile.gettempdir(). This directory is inserted at the beginning of
+ All files are created in a temporary directory returned by
+ tempfile.mkdtemp(). This directory is inserted at the beginning of
sys.path. When the context manager exits all created files (source and
bytecode) are explicitly deleted.

@@ -58,7 +58,7 @@
state_manager = None
uncache_manager = None
try:
- temp_dir = tempfile.gettempdir()
+ temp_dir = tempfile.mkdtemp()
mapping['.root'] = temp_dir
import_names = set()
for name in names:
@@ -91,11 +91,4 @@
state_manager.__exit__(None, None, None)
if uncache_manager is not None:
uncache_manager.__exit__(None, None, None)
- # Reverse the order for path removal to unroll directory creation.
- for path in reversed(created_paths):
- if file_path.endswith('.py'):
- support.unlink(path)
- support.unlink(path + 'c')
- support.unlink(path + 'o')
- else:
- os.rmdir(path)
+ support.rmtree(temp_dir)

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Thu Nov 5 02:26:57 2009
@@ -354,6 +354,10 @@
Tests
-----

+- Issue #7248 (part 2): Use a unique temporary directory for importlib source
+ tests instead of tempfile.tempdir. This prevents the tests from sharing state
+ between concurrent executions on the same system.
+
- Issue #7248: In importlib.test.source.util a try/finally block did not make
sure that some referenced objects actually were created in the block before
calling methods on the object.
_______________________________________________
Python-checkins mailing list
Python-checkins[at]python.org
http://mail.python.org/mailman/listinfo/python-checkins

Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.