File: run_tests.py

package info (click to toggle)
ubelt 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,180 kB
  • sloc: python: 15,487; sh: 807; makefile: 24
file content (47 lines) | stat: -rwxr-xr-x 1,246 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
import sys


def get_this_script_fpath():
    import pathlib
    try:
        fpath = pathlib.Path(__file__)
    except NameError:
        # This is not being run from a script, thus the developer is doing some
        # IPython hacking, so we will assume a path on the developer machine.
        fpath = pathlib.Path('~/code/ubelt/run_tests.py').expanduser()
        if not fpath.exists():
            raise Exception(
                'Unable to determine the file path that this script '
                'should correspond to')
    return fpath


def main():
    import pytest
    import os

    repo_dpath = get_this_script_fpath().parent

    package_name = 'ubelt'
    mod_dpath = repo_dpath / 'ubelt'
    test_dpath = repo_dpath / 'tests'
    config_fpath = repo_dpath / 'pyproject.toml'

    pytest_args = [
        '--cov-config', os.fspath(config_fpath),
        '--cov-report', 'html',
        '--cov-report', 'term',
        '--durations', '100',
        '--xdoctest',
        '--cov=' + package_name,
        os.fspath(mod_dpath),
        os.fspath(test_dpath)
    ]
    pytest_args = pytest_args + sys.argv[1:]
    ret = pytest.main(pytest_args)
    return ret


if __name__ == '__main__':
    sys.exit(main())