summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test__datasource.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-09-02 13:21:48 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-09-03 05:22:10 -0600
commitd2c44c5a012d0a5db7d10a2586c8e9c58045d04b (patch)
treeb93306d17c5460a68d7e7fb29e6be729ad2a28dd /numpy/lib/tests/test__datasource.py
parent57245e4570fa84f2e40a6fa1cc22716d279f8c00 (diff)
downloadnumpy-d2c44c5a012d0a5db7d10a2586c8e9c58045d04b.tar.gz
STY: Make numpy/lib/test/*.py PEP8 compliant.
Run autopep8 over the test files in numpy/lib/test and make fixes to the result. Also remove Python5 workaround.
Diffstat (limited to 'numpy/lib/tests/test__datasource.py')
-rw-r--r--numpy/lib/tests/test__datasource.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py
index 8d3e32b1b..f61d3086b 100644
--- a/numpy/lib/tests/test__datasource.py
+++ b/numpy/lib/tests/test__datasource.py
@@ -17,6 +17,7 @@ else:
from urlparse import urlparse
from urllib2 import URLError
+
def urlopen_stub(url, data=None):
'''Stub to replace urlopen for testing.'''
if url == valid_httpurl():
@@ -28,12 +29,14 @@ def urlopen_stub(url, data=None):
# setup and teardown
old_urlopen = None
+
def setup():
global old_urlopen
old_urlopen = urllib_request.urlopen
urllib_request.urlopen = urlopen_stub
+
def teardown():
urllib_request.urlopen = old_urlopen
@@ -57,6 +60,7 @@ def valid_textfile(filedir):
os.close(fd)
return path
+
def invalid_textfile(filedir):
# Generate and return an invalid filename.
fd, path = mkstemp(suffix='.txt', prefix='dstmp_', dir=filedir)
@@ -64,24 +68,31 @@ def invalid_textfile(filedir):
os.remove(path)
return path
+
def valid_httpurl():
return http_path+http_file
+
def invalid_httpurl():
return http_fakepath+http_fakefile
+
def valid_baseurl():
return http_path
+
def invalid_baseurl():
return http_fakepath
+
def valid_httpfile():
return http_file
+
def invalid_httpfile():
return http_fakefile
+
class TestDataSourceOpen(TestCase):
def setUp(self):
self.tmpdir = mkdtemp()
@@ -259,7 +270,7 @@ class TestRepositoryAbspath(TestCase):
def test_ValidHTTP(self):
scheme, netloc, upath, pms, qry, frg = urlparse(valid_httpurl())
- local_path = os.path.join(self.repos._destpath, netloc, \
+ local_path = os.path.join(self.repos._destpath, netloc,
upath.strip(os.sep).strip('/'))
filepath = self.repos.abspath(valid_httpfile())
self.assertEqual(local_path, filepath)
@@ -313,6 +324,7 @@ class TestRepositoryExists(TestCase):
tmpfile = valid_textfile(local_path)
assert_(self.repos.exists(tmpfile))
+
class TestOpenFunc(TestCase):
def setUp(self):
self.tmpdir = mkdtemp()