test2.py: switch from urllib to urllib2
authorRoman Donchenko <roman.donchenko@itseez.com>
Thu, 17 Sep 2015 15:21:04 +0000 (18:21 +0300)
committerRoman Donchenko <roman.donchenko@itseez.com>
Thu, 17 Sep 2015 15:24:30 +0000 (18:24 +0300)
urllib2 raises an exception if an HTTP request produces an error code,
making the test fail earlier.

modules/python/test/test2.py

index 4cd67e7..815993e 100644 (file)
@@ -2,7 +2,7 @@
 
 import unittest
 import random
-import urllib
+import urllib2
 import hashlib
 import numpy as np
 import cv2
@@ -12,7 +12,7 @@ class NewOpenCVTests(unittest.TestCase):
 
     def get_sample(self, filename, iscolor = cv.CV_LOAD_IMAGE_COLOR):
         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)
             self.assertFalse(image is None)
             self.image_cache[filename] = image