From 3ee8079f355329249bdd3ea1328c4cbbe8159e09 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 28 Aug 2017 17:26:49 +0300 Subject: [PATCH 1/2] python(test): add tests filter Usage example (bash): $ OPENCV_PYTEST_FILTER=test_digits python test.py -v --- modules/python/test/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/python/test/test.py b/modules/python/test/test.py index 7d9bba4fc2..aac5d74270 100755 --- a/modules/python/test/test.py +++ b/modules/python/test/test.py @@ -17,7 +17,7 @@ from tests_common import NewOpenCVTests basedir = os.path.abspath(os.path.dirname(__file__)) def load_tests(loader, tests, pattern): - tests.addTests(loader.discover(basedir, pattern='test_*.py')) + tests.addTests(loader.discover(basedir, pattern=os.environ.get('OPENCV_PYTEST_FILTER', 'test_') + '*.py')) return tests if __name__ == '__main__': From 019de554a03f0e312af5e926e138aa13129d057f Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 23 Nov 2017 13:08:26 +0300 Subject: [PATCH 2/2] python(test): don't write bytecode Tests are usually lauched from source directory, so additional unnecessary files should be eliminated. Alternative ways (command line): - python -B ... - PYTHONDONTWRITEBYTECODE=1 python ... --- modules/python/test/test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/python/test/test.py b/modules/python/test/test.py index aac5d74270..249a354636 100755 --- a/modules/python/test/test.py +++ b/modules/python/test/test.py @@ -2,6 +2,9 @@ from __future__ import print_function +import sys +sys.dont_write_bytecode = True # Don't generate .pyc files / __pycache__ directories + import os import unittest