Commit 08ad3b50 authored by Roman Donchenko's avatar Roman Donchenko

test2.py: switch from urllib to urllib2

urllib2 raises an exception if an HTTP request produces an error code,
making the test fail earlier.
parent 56f17e49
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import unittest import unittest
import random import random
import urllib import urllib2
import hashlib import hashlib
import numpy as np import numpy as np
import cv2 import cv2
...@@ -12,7 +12,7 @@ class NewOpenCVTests(unittest.TestCase): ...@@ -12,7 +12,7 @@ class NewOpenCVTests(unittest.TestCase):
def get_sample(self, filename, iscolor = cv.CV_LOAD_IMAGE_COLOR): def get_sample(self, filename, iscolor = cv.CV_LOAD_IMAGE_COLOR):
if not filename in self.image_cache: if not filename in self.image_cache:
filedata = urllib.urlopen("https://raw.github.com/Itseez/opencv/2.4/" + filename).read() filedata = urllib2.urlopen("https://raw.github.com/Itseez/opencv/2.4/" + filename).read()
image = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor) image = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor)
self.assertFalse(image is None) self.assertFalse(image is None)
self.image_cache[filename] = image self.image_cache[filename] = image
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment