HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/root/home/arjun/projects/buyercall_forms/buyercall/cli/commands/cmd_test.py
import logging
import subprocess

import click

try:
    from instance import settings

    APP_ROOT = settings.APP_ROOT
except ImportError:
    logging.error('Ensure __init__.py and settings.py both exist in instance/')
    exit(1)
except AttributeError:
    from config import settings

    APP_ROOT = settings.APP_ROOT

TESTS_PATH = '{0}/{1}'.format(APP_ROOT, '/buyercall/tests')


@click.command()
@click.argument('path', default=TESTS_PATH)
@click.option('-k', default='', help="Regular expression to filter tests by")
@click.option('-s', is_flag=True, default=False, help="Disable stdout capturing")
def cli(path, k, s):
    """
    Run tests.

    :return: Subprocess call result
    """
    cmd = 'py.test {0}'.format(path)
    if k:
        cmd += ' -k {}'.format(k)
    if s:
        cmd += ' -s'
    return subprocess.call(cmd, shell=True)