diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/tests/test__datasource.py | 18 | ||||
-rw-r--r-- | numpy/lib/tests/test_format.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_regression.py | 24 |
3 files changed, 27 insertions, 17 deletions
diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py index a4a490ed2..ed5af516f 100644 --- a/numpy/lib/tests/test__datasource.py +++ b/numpy/lib/tests/test__datasource.py @@ -83,7 +83,9 @@ class TestDataSourceOpen(TestCase): del self.ds def test_ValidHTTP(self): - assert self.ds.open(valid_httpurl()) + fh = self.ds.open(valid_httpurl()) + assert_(fh) + fh.close() def test_InvalidHTTP(self): url = invalid_httpurl() @@ -92,14 +94,16 @@ class TestDataSourceOpen(TestCase): self.ds.open(url) except IOError, e: # Regression test for bug fixed in r4342. - assert e.errno is None + 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) + fh = self.ds.open(local_file) + assert_(fh) + fh.close() def test_InvalidFile(self): invalid_file = invalid_textfile(self.tmpdir) @@ -310,9 +314,13 @@ class TestOpenFunc(TestCase): def test_DataSourceOpen(self): local_file = valid_textfile(self.tmpdir) # Test case where destpath is passed in - assert datasource.open(local_file, destpath=self.tmpdir) + fp = datasource.open(local_file, destpath=self.tmpdir) + assert_(fp) + fp.close() # Test case where default destpath is used - assert datasource.open(local_file) + fp = datasource.open(local_file) + assert_(fp) + fp.close() if __name__ == "__main__": diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 2e6935141..ff8e93704 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -463,7 +463,7 @@ def test_memmap_roundtrip(): # Check that reading the file using memmap works. ma = format.open_memmap(nfn, mode='r') #yield assert_array_equal, ma, arr - #del ma + del ma def test_write_version_1_0(): diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py index a67355957..0e63fb08c 100644 --- a/numpy/lib/tests/test_regression.py +++ b/numpy/lib/tests/test_regression.py @@ -70,8 +70,8 @@ class TestRegression(TestCase): """Ticket #554""" x = np.poly1d([1,2,3]) y = np.poly1d([3,4]) - assert x != y - assert x == x + assert_(x != y) + assert_(x == x) def test_mem_insert(self, level=rlevel): """Ticket #572""" @@ -152,19 +152,21 @@ class TestRegression(TestCase): def test_void_coercion(self, level=rlevel): dt = np.dtype([('a','f4'),('b','i4')]) x = np.zeros((1,),dt) - assert(np.r_[x,x].dtype == dt) + assert_(np.r_[x,x].dtype == dt) def test_who_with_0dim_array(self, level=rlevel) : """ticket #1243""" import os, sys + oldstdout = sys.stdout sys.stdout = open(os.devnull, 'w') - try : - tmp = np.who({'foo' : np.array(1)}) - sys.stdout = sys.__stdout__ - except : - sys.stdout = sys.__stdout__ - raise AssertionError("ticket #1243") + try: + try: + tmp = np.who({'foo' : np.array(1)}) + except: + raise AssertionError("ticket #1243") + finally: + sys.stdout = oldstdout def test_bincount_empty(self): """Ticket #1387: empty array as input for bincount.""" @@ -178,8 +180,8 @@ class TestRegression(TestCase): include_dirs = [np.get_include(), np.get_numarray_include(), np.get_numpy_include()] for path in include_dirs: - assert isinstance(path, (str, unicode)) - assert path != '' + assert_(isinstance(path, (str, unicode))) + assert_(path != '') def test_polyder_return_type(self): """Ticket #1249""" |