mirror of
https://github.com/OpenFreeEnergy/openfe.git
synced 2026-06-04 22:34:24 +08:00
* exit with the return value of pytest.main when running openfe test * always restore env
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
import click
|
|
from openfecli import OFECommandPlugin
|
|
import sys
|
|
|
|
import pytest
|
|
import os
|
|
|
|
from openfecli.utils import write
|
|
|
|
@click.command(
|
|
"test",
|
|
short_help="Run the OpenFE test suite"
|
|
)
|
|
@click.option('--long', is_flag=True, default=False,
|
|
help="Run additional tests (takes much longer)")
|
|
def test(long):
|
|
"""
|
|
Run the OpenFE test suite. This first checks that OpenFE is correctly
|
|
imported, and then runs the main test suite, which should take several
|
|
minutes. If given the ``--long`` flag, this will include several tests
|
|
that take significantly longer, but ensure that we're able to fully run
|
|
in your environment.
|
|
|
|
A successful run will include tests that pass, skip, or "xfail". In many
|
|
terminals, these show as green or yellow. Warnings are not a concern.
|
|
However, You should not see anything that fails or errors (red).
|
|
"""
|
|
try:
|
|
old_env = dict(os.environ)
|
|
os.environ["OFE_SLOW_TESTS"] = str(long)
|
|
|
|
write("Testing can import....")
|
|
import openfe
|
|
write("Running the main package tests")
|
|
return_value = pytest.main(["-v", "--pyargs", "openfe", "--pyargs", "openfecli"])
|
|
finally:
|
|
os.environ.clear()
|
|
os.environ.update(old_env)
|
|
sys.exit(return_value)
|
|
|
|
PLUGIN = OFECommandPlugin(
|
|
test,
|
|
"Miscellaneous",
|
|
requires_ofe=(0, 7,5)
|
|
)
|