Skip to content

Commit dc27588

Browse files
author
Lee Kamentsky
committed
Made robust URL test
1 parent 2f10961 commit dc27588

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

bioformats/tests/test_formatreader.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import numpy as np
1313
import os
1414
import re
15+
import urllib
1516
import unittest
1617

1718
import javabridge as J
@@ -154,24 +155,20 @@ def test_03_03_read_subimage_tif(self):
154155
self.assertTrue(np.all(expected_0_10_0_10 == data_0_10_0_10))
155156
# self.assertTrue(np.all(expected_n10_n10 == data[-10:,-10:]))
156157

157-
# def test_03_03_load_using_bioformats_url(self):
158-
# data = F.load_using_bioformats_url(
159-
# "http://www.cellprofiler.org/linked_files/broad-logo.gif",
160-
# rescale=False)
161-
# self.assertSequenceEqual(data.shape, (38, 150, 3))
162-
# expected_0_10_0_10 = np.array([
163-
# [181, 176, 185, 185, 175, 175, 176, 195, 187, 185],
164-
# [ 25, 7, 7, 7, 2, 2, 13, 13, 0, 1],
165-
# [ 21, 1, 1, 0, 0, 1, 0, 1, 0, 0],
166-
# [ 64, 13, 1, 1, 12, 12, 2, 1, 1, 1],
167-
# [ 22, 56, 26, 13, 1, 1, 6, 0, 0, 0],
168-
# [ 12, 13, 82, 57, 9, 12, 2, 6, 6, 6],
169-
# [ 12, 13, 20, 89, 89, 21, 11, 12, 1, 0],
170-
# [ 6, 1, 7, 21, 89, 102, 26, 0, 10, 1],
171-
# [ 26, 0, 0, 1, 20, 84, 151, 58, 12, 1],
172-
# [ 23, 6, 1, 1, 0, 1, 55, 166, 100, 12]],
173-
# dtype=np.uint8)
174-
# self.assertTrue(np.all(expected_0_10_0_10 == data[:10,:10, 0]))
158+
def test_03_03_load_using_bioformats_url(self):
159+
url = "https://github.com/CellProfiler/python-bioformats/raw/1.0.5/bioformats/tests/Channel1-01-A-01.tif"
160+
try:
161+
fd = urllib.urlopen(url)
162+
if fd.code < 200 or fd.code >= 300:
163+
raise IOError("Http error %d" % fd.code)
164+
except IOError, e:
165+
def bad_url(e=e):
166+
print "bad url"
167+
raise e
168+
unittest.expectedFailure(bad_url)()
169+
170+
data = F.load_using_bioformats_url(url, rescale=False)
171+
self.assertSequenceEqual(data.shape, (640, 640))
175172

176173
def test_04_01_read_omexml_metadata(self):
177174
path = os.path.join(os.path.dirname(__file__), 'Channel1-01-A-01.tif')

0 commit comments

Comments
 (0)