opencv/modules/python/test/test.py

53 lines
1.6 KiB
Python
Raw Normal View History

#!/usr/bin/env python
from __future__ import print_function
import unittest
import random
import time
import math
import sys
import array
import tarfile
import hashlib
import os
import getopt
import operator
import functools
import numpy as np
import cv2
import argparse
# Python 3 moved urlopen to urllib.requests
try:
from urllib.request import urlopen
except ImportError:
from urllib import urlopen
2016-01-28 20:43:08 +08:00
from tests_common import NewOpenCVTests
2013-04-12 21:39:16 +08:00
# Tests to run first; check the handful of basic operations that the later tests rely on
basedir = os.path.abspath(os.path.dirname(__file__))
def load_tests(loader, tests, pattern):
tests.addTests(loader.discover(basedir, pattern='test_*.py'))
return tests
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='run OpenCV python tests')
parser.add_argument('--repo', help='use sample image files from local git repository (path to folder), '
'if not set, samples will be downloaded from github.com')
parser.add_argument('--data', help='<not used> use data files from local folder (path to folder), '
'if not set, data files will be downloaded from docs.opencv.org')
args, other = parser.parse_known_args()
print("Testing OpenCV", cv2.__version__)
print("Local repo path:", args.repo)
NewOpenCVTests.repoPath = args.repo
2016-02-05 23:46:43 +08:00
try:
NewOpenCVTests.extraTestDataPath = os.environ['OPENCV_TEST_DATA_PATH']
except KeyError:
2016-02-24 18:09:42 +08:00
print('Missing opencv extra repository. Some of tests may fail.')
random.seed(0)
unit_argv = [sys.argv[0]] + other
unittest.main(argv=unit_argv)