[Python-checkins] r55197 - python/trunk/Lib/test/test_support.py

collin.winter python-checkins at python.org
Wed May 9 06:14:47 CEST 2007


Author: collin.winter
Date: Wed May  9 06:14:36 2007
New Revision: 55197

Modified:
   python/trunk/Lib/test/test_support.py
Log:
Fix a bug in test.test_support.open_urlresource().

If the call to requires() doesn't precede the filesystem check, we get the following situation:
1. ./python Lib/test/regrtest.py test_foo # test needs urlfetch, not enabled, so skipped
2. ./python Lib/test/regrtest.py -u urlfetch test_foo # test runs
3. ./python Lib/test/regrtest.py test_foo # test runs (!)

By moving the call to requires() *after* the filesystem check, the fact that fetched files are cached on the local disk becomes an implementation detail, rather than a semantics-changing point of note.


Modified: python/trunk/Lib/test/test_support.py
==============================================================================
--- python/trunk/Lib/test/test_support.py	(original)
+++ python/trunk/Lib/test/test_support.py	Wed May  9 06:14:36 2007
@@ -259,6 +259,7 @@
 def open_urlresource(url):
     import urllib, urlparse
 
+    requires('urlfetch')
     filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL!
 
     for path in [os.path.curdir, os.path.pardir]:
@@ -266,7 +267,6 @@
         if os.path.exists(fn):
             return open(fn)
 
-    requires('urlfetch')
     print >> get_original_stdout(), '\tfetching %s ...' % url
     fn, _ = urllib.urlretrieve(url, filename)
     return open(fn)


More information about the Python-checkins mailing list