Skip to content

Commit 05cf868

Browse files
Copilotmelund
andauthored
fix: pytest plugin to fail tests when anybodycon is not available (#143)
* Initial plan * Fix pytest plugin to fail tests when anybodycon is not available Add early check in AnyTestItem.runtest() to raise a proper test failure when the AnyBodyCon executable cannot be found, instead of silently passing with an unhandled thread exception. Also add test_no_anybodycon pixi environment and CI job to verify .any tests correctly fail without anybodycon installed. Fixes #142 Co-authored-by: melund <1038978+melund@users.noreply.github.com> * Address code review: fix pytest.fail() usage and simplify CI shell logic Co-authored-by: melund <1038978+melund@users.noreply.github.com> * Change test-no-anybodycon CI job to run on windows-latest Switch the runner from ubuntu-latest to windows-latest and add shell: bash since the ! negation operator requires bash (not PowerShell, the default on Windows runners). Co-authored-by: melund <1038978+melund@users.noreply.github.com> * Rename pixi env to test-no-anybodycon (dashes) and run pixi lock Pixi requires environment names to use only lowercase letters, numbers and dashes. Renamed test_no_anybodycon to test-no-anybodycon in pixi.toml and the workflow file, then ran pixi lock to regenerate the lock file. Co-authored-by: melund <1038978+melund@users.noreply.github.com> * Fix black formatting in pytest_plugin.py Collapse multi-line if condition to single line to match black's expected formatting and pass CI lint check. Co-authored-by: melund <1038978+melund@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: melund <1038978+melund@users.noreply.github.com>
1 parent f095b88 commit 05cf868

4 files changed

Lines changed: 999 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ jobs:
4242
RLM_LICENSE_PASSWORD: ${{ secrets.LICENSE_PASSWORD }}
4343
RLM_LICENSE: ${{ secrets.LICENSE_SERVER }}
4444

45+
test-no-anybodycon:
46+
runs-on: windows-latest
47+
needs: lint
48+
steps:
49+
- uses: actions/checkout@v6
50+
51+
- uses: prefix-dev/setup-pixi@v0.9.3
52+
with:
53+
environments: test-no-anybodycon
54+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
55+
56+
- name: Test that .any tests fail without anybodycon
57+
shell: bash
58+
run: |
59+
! pixi run -e test-no-anybodycon pytest tests/test_Arm2D.any --no-header -rN
60+
4561
4662
# Linux builds have started failing with AMS 8.1 due to some WINE issue:
4763
# ----------------------------- Captured stderr call -----------------------------

anypytools/pytest_plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,13 @@ def __init__(self, name, id, parent, any_defs, any_paths, **kwargs):
377377

378378
def runtest(self):
379379
"""Run an AnyScript test item."""
380+
if not pytest.anytest.ams_path or not os.path.isfile(pytest.anytest.ams_path):
381+
pytest.fail(
382+
f"AnyBodyCon executable not found: '{pytest.anytest.ams_path}'. "
383+
"Ensure AnyBodyCon is installed and available on PATH or specify "
384+
"the path with --anybodycon.",
385+
pytrace=False,
386+
)
380387

381388
tmpdir = TempPathFactory.from_config(self.config, _ispytest=True).mktemp(
382389
self.name

0 commit comments

Comments
 (0)