#1784 - init commit of pype command

Pype command is better than run_tests.ps1 as OP is initialized by start.py. This is more similar to standard running of OP
This commit is contained in:
Petr Kalis 2021-09-08 18:46:56 +02:00
parent 331de6de75
commit 777facc69c
2 changed files with 36 additions and 0 deletions

View file

@ -283,3 +283,18 @@ def run(script):
args_string = " ".join(args[1:])
print(f"... running: {script} {args_string}")
runpy.run_path(script, run_name="__main__", )
@main.command()
@click.argument("folder", nargs=-1)
@click.option("-m",
"--mark",
help="Run tests marked by",
default=None)
@click.option("-p",
"--pyargs",
help="Run tests from package",
default=None)
def runtests(folder, mark, pyargs):
"""Run all automatic tests after proper initialization via start.py"""
PypeCommands().run_tests(folder, mark, pyargs)

View file

@ -257,3 +257,24 @@ class PypeCommands:
def validate_jsons(self):
pass
def run_tests(self, folder, mark, pyargs):
"""
Runs tests from 'folder'
Args:
folder (str): relative path to folder with tests
mark (str): label to run tests marked by it (slow etc)
pyargs (str): package path to test
"""
print("run_tests")
import subprocess
folder = folder or "../tests"
mark_str = pyargs_str = ''
if mark:
mark_str = "- m {}".format(mark)
if pyargs:
pyargs_str = "--pyargs {}".format(pyargs)
subprocess.run("pytest {} {} {}".format(folder, mark_str, pyargs_str))