Skip to content

Commit

Permalink
Made robust URL test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Kamentsky committed Mar 2, 2016
1 parent 2f10961 commit dc27588
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions bioformats/tests/test_formatreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import numpy as np
import os
import re
import urllib
import unittest

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

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

data = F.load_using_bioformats_url(url, rescale=False)
self.assertSequenceEqual(data.shape, (640, 640))

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

0 comments on commit dc27588

Please sign in to comment.