[Numpy-svn] r5415 - in branches/1.1.x/numpy/lib: . tests

numpy-svn@scip... numpy-svn@scip...
Tue Jul 15 03:02:23 CDT 2008


Author: rkern
Date: 2008-07-15 03:02:21 -0500 (Tue, 15 Jul 2008)
New Revision: 5415

Modified:
   branches/1.1.x/numpy/lib/_datasource.py
   branches/1.1.x/numpy/lib/tests/test__datasource.py
Log:
Backport r5342.

Modified: branches/1.1.x/numpy/lib/_datasource.py
===================================================================
--- branches/1.1.x/numpy/lib/_datasource.py	2008-07-15 08:01:26 UTC (rev 5414)
+++ branches/1.1.x/numpy/lib/_datasource.py	2008-07-15 08:02:21 UTC (rev 5415)
@@ -209,14 +209,14 @@
                 openedurl = urlopen(path)
                 file(upath, 'w').write(openedurl.read())
             except URLError:
-                raise URLError("URL not found: ", path)
+                raise URLError("URL not found: %s" % path)
         else:
             try:
                 # TODO: Why not just copy the file with shutils.copyfile?
                 fp = file(path, 'r')
                 file(upath, 'w').write(fp.read())
             except IOError:
-                raise IOError("File not found: ", path)
+                raise IOError("File not found: %s" % path)
         return upath
 
     def _findfile(self, path):

Modified: branches/1.1.x/numpy/lib/tests/test__datasource.py
===================================================================
--- branches/1.1.x/numpy/lib/tests/test__datasource.py	2008-07-15 08:01:26 UTC (rev 5414)
+++ branches/1.1.x/numpy/lib/tests/test__datasource.py	2008-07-15 08:02:21 UTC (rev 5415)
@@ -80,8 +80,17 @@
         assert self.ds.open(valid_httpurl())
 
     def test_InvalidHTTP(self):
-        self.assertRaises(IOError, self.ds.open, invalid_httpurl())
+        url = invalid_httpurl()
+        self.assertRaises(IOError, self.ds.open, url)
+        try:
+            self.ds.open(url)
+        except IOError, e:
+            # Regression test for bug fixed in r4342.
+            assert e.errno is None
 
+    def test_InvalidHTTPCacheURLError(self):
+        self.assertRaises(datasource.URLError, self.ds._cache, invalid_httpurl())
+
     def test_ValidFile(self):
         local_file = valid_textfile(self.tmpdir)
         assert self.ds.open(local_file)



More information about the Numpy-svn mailing list