forked from binref/refinery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.py
More file actions
executable file
·27 lines (22 loc) · 775 Bytes
/
run-tests.py
File metadata and controls
executable file
·27 lines (22 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Runs all tests from the command line.
"""
import argparse
import unittest
import os
import sys
from inspect import stack
from refinery.lib.environment import environment, LogLevel
here = os.path.dirname(os.path.abspath(stack()[0][1]))
argp = argparse.ArgumentParser()
argp.add_argument('pattern', type=lambda s: str(s).strip('*'), nargs='?', default='*',
help='run all tests whose file name contains the given pattern.')
args = argp.parse_args()
os.chdir('test')
os.environ[environment.verbosity.key] = LogLevel.DETACHED.name
suite = unittest.TestLoader().discover('test', F'test_*{args.pattern}*')
tests = unittest.TextTestRunner(verbosity=2)
result = tests.run(suite)
sys.exit(0 if result.wasSuccessful() else 1)