[Numpy-svn] r5342 - in trunk/numpy/lib: . tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Thu Jul 3 02:59:31 EDT 2008
Author: rkern
Date: 2008-07-03 01:59:29 -0500 (Thu, 03 Jul 2008)
New Revision: 5342
Modified:
trunk/numpy/lib/_datasource.py
trunk/numpy/lib/tests/test__datasource.py
Log:
BUG: need to create exceptions correctly.
Modified: trunk/numpy/lib/_datasource.py
===================================================================
--- trunk/numpy/lib/_datasource.py 2008-07-03 06:42:28 UTC (rev 5341)
+++ trunk/numpy/lib/_datasource.py 2008-07-03 06:59:29 UTC (rev 5342)
@@ -211,14 +211,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: trunk/numpy/lib/tests/test__datasource.py
===================================================================
--- trunk/numpy/lib/tests/test__datasource.py 2008-07-03 06:42:28 UTC (rev 5341)
+++ trunk/numpy/lib/tests/test__datasource.py 2008-07-03 06:59:29 UTC (rev 5342)
@@ -81,8 +81,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(URLError, self.ds._cache, invalid_httpurl())
+
def test_ValidFile(self):
local_file = valid_textfile(self.tmpdir)
assert self.ds.open(local_file)
@@ -95,10 +104,9 @@
try:
import gzip
except ImportError:
- # We don't have the bz2 capabilities to test.
- # FIXME: when we start using nose, raise a SkipTest rather than
- # passing the test.
- return
+ # We don't have the gzip capabilities to test.
+ import nose
+ raise nose.SkipTest
# Test datasource's internal file_opener for Gzip files.
filepath = os.path.join(self.tmpdir, 'foobar.txt.gz')
fp = gzip.open(filepath, 'w')
@@ -114,9 +122,8 @@
import bz2
except ImportError:
# We don't have the bz2 capabilities to test.
- # FIXME: when we start using nose, raise a SkipTest rather than
- # passing the test.
- return
+ import nose
+ raise nose.SkipTest
# Test datasource's internal file_opener for BZip2 files.
filepath = os.path.join(self.tmpdir, 'foobar.txt.bz2')
fp = bz2.BZ2File(filepath, 'w')
@@ -288,7 +295,6 @@
tmpfile = valid_textfile(local_path)
assert self.repos.exists(tmpfile)
-
class TestOpenFunc(TestCase):
def setUp(self):
self.tmpdir = mkdtemp()
More information about the Numpy-svn
mailing list