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)") # fmt: skip 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))