diff options
author | Robert Kern <robert.kern@gmail.com> | 2008-07-03 06:59:29 +0000 |
---|---|---|
committer | Robert Kern <robert.kern@gmail.com> | 2008-07-03 06:59:29 +0000 |
commit | 638f015c904d32e0f89604d088731a3ad2daccfd (patch) | |
tree | c9357546bd58a361b2fca2bbff75c1b6b0cbb294 /numpy/lib/tests/test__datasource.py | |
parent | f912322ee454fee1d15da01c5fd951ab2fcb5f99 (diff) | |
download | numpy-638f015c904d32e0f89604d088731a3ad2daccfd.tar.gz |
BUG: need to create exceptions correctly.
Diffstat (limited to 'numpy/lib/tests/test__datasource.py')
-rw-r--r-- | numpy/lib/tests/test__datasource.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py index 5102237d6..d55e52973 100644 --- a/numpy/lib/tests/test__datasource.py +++ b/numpy/lib/tests/test__datasource.py @@ -81,7 +81,16 @@ class TestDataSourceOpen(TestCase): 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) @@ -95,10 +104,9 @@ class TestDataSourceOpen(TestCase): 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 @@ class TestDataSourceOpen(TestCase): 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 @@ class TestRepositoryExists(TestCase): tmpfile = valid_textfile(local_path) assert self.repos.exists(tmpfile) - class TestOpenFunc(TestCase): def setUp(self): self.tmpdir = mkdtemp() |