Skip to content

Commit 81cb7c0

Browse files
Test that range_width is working with opencv 4.7 (#42)
* updated test imgs and download strategy * deleted old and skipped performance comparison test * add range width test
1 parent 821dbe4 commit 81cb7c0

5 files changed

Lines changed: 63 additions & 564 deletions

File tree

tests/__init__.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22

33
import os
44
import shutil
5+
from urllib.parse import urlparse
56

67
import requests
78

89
TEST_DIR = os.path.abspath(os.path.dirname(__file__))
910
os.chdir(os.path.join(TEST_DIR, "testdata"))
1011

1112

12-
def download_img(url, img):
13-
r = requests.get(url + img, stream=True)
13+
def download_img(url, img_name):
14+
r = requests.get(url, stream=True)
1415
if r.status_code == 200:
15-
with open(img, "wb") as f:
16+
parse = urlparse(url)
17+
img_name = os.path.basename(parse.path)
18+
with open(img_name, "wb") as f:
1619
r.raw.decode_content = True
1720
shutil.copyfileobj(r.raw, f)
1821
else:
19-
raise Exception("Failed to download " + url + img)
22+
raise Exception("Failed to download " + url)
2023

2124

2225
with open("TEST_IMAGES.txt", "r") as f:
23-
required_imgs = f.read().splitlines()
24-
download_url = required_imgs.pop(0)
26+
img_urls = f.read().splitlines()
27+
img_names = [os.path.basename(urlparse(url).path) for url in img_urls]
2528

26-
for img in required_imgs:
27-
if not os.path.isfile(img):
28-
print("Downloading " + img)
29-
download_img(download_url, img)
29+
for url, img_name in zip(img_urls, img_names):
30+
if not os.path.isfile(img_name):
31+
print("Downloading " + img_name)
32+
download_img(url, img_name)

0 commit comments

Comments
 (0)