From 4adaf0048345bb62abb1ff5968f0ade50d8efd7f Mon Sep 17 00:00:00 2001 From: Martin Lang Date: Sat, 21 May 2022 09:21:02 +0200 Subject: [PATCH 1/2] Fix running multiple test commands via invoke --- tasks.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tasks.py b/tasks.py index e4b93dc..2268d3a 100644 --- a/tasks.py +++ b/tasks.py @@ -18,7 +18,6 @@ def unittest(c): """Run unittests.""" import mag2exp - result = mag2exp.test() raise Exit(code=result) @@ -46,9 +45,16 @@ def ipynb(c): raise Exit(code=result) -@task(unittest, docs, ipynb) +@task def all(c): """Run all tests.""" + for cmd in (unittest, docs, ipynb): + try: + cmd(c) + except Exit as e: + if e.code != pytest.ExitCode.OK: + raise e + raise Exit(code=pytest.ExitCode.OK) test_collection.add_task(unittest) @@ -93,15 +99,19 @@ def release(c): raise Exit("Working tree is not clean. Aborting.") # run all tests - all(c) + try: + all(c) + except Exit as e: + if e.code != pytest.ExitCode.OK: + raise e version = iniconfig.IniConfig("setup.cfg").get("metadata", "version") # sanity checks while we have two places containing the version. with open("pyproject.toml", "rb") as f: toml_version = tomli.load(f)["project"]["version"] - assert ( - toml_version == version - ), "Different versions in pyproject.toml and setup.cfg. Aborting." + assert toml_version == version, ( + "Different versions in pyproject.toml and setup.cfg. Aborting." + ) c.run(f"git tag {version}") # fails if the tag exists c.run("git tag -f latest") # `latest` tag for binder From 16174ef859e7146ef520e45d93a0f0af70916df1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 21 May 2022 07:22:31 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tasks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tasks.py b/tasks.py index 2268d3a..36b6a2f 100644 --- a/tasks.py +++ b/tasks.py @@ -18,6 +18,7 @@ def unittest(c): """Run unittests.""" import mag2exp + result = mag2exp.test() raise Exit(code=result) @@ -109,9 +110,9 @@ def release(c): # sanity checks while we have two places containing the version. with open("pyproject.toml", "rb") as f: toml_version = tomli.load(f)["project"]["version"] - assert toml_version == version, ( - "Different versions in pyproject.toml and setup.cfg. Aborting." - ) + assert ( + toml_version == version + ), "Different versions in pyproject.toml and setup.cfg. Aborting." c.run(f"git tag {version}") # fails if the tag exists c.run("git tag -f latest") # `latest` tag for binder