forked from spyder-ide/spyder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
67 lines (52 loc) · 1.57 KB
/
runtests.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
#
"""
File for running tests programmatically.
"""
# Standard library imports
import os
import os.path as osp
import shutil
# Third party imports
import qtpy # to ensure that Qt4 uses API v2
import pytest
# To activate/deactivate certain things for pytest's only
os.environ['SPYDER_PYTEST'] = 'True'
# Tests expect English as the interface language
os.environ['LANG'] = 'en'
# To run our slow tests only in our CIs
run_slow = False
if os.environ.get('CI', None) is not None:
run_slow = True
def main():
"""
Run pytest tests.
"""
# Remove temp conf_dir before starting the tests
from spyder.config.base import get_conf_path
conf_dir = get_conf_path()
if osp.isdir(conf_dir):
shutil.rmtree(conf_dir)
pytest_args = ['spyder',
'spyder_profiler',
'-x',
'-vv',
'-rw',
'--durations=10',
'--cov=spyder',
'--cov=spyder_profiler',
'--cov-report=term-missing']
if run_slow:
pytest_args.append('--run-slow')
errno = pytest.main(pytest_args)
# sys.exit doesn't work here because some things could be running
# in the background (e.g. closing the main window) when this point
# is reached. And if that's the case, sys.exit does't stop the
# script (as you would expected).
if errno != 0:
raise SystemExit(errno)
if __name__ == '__main__':
main()