diff --git a/.gitignore b/.gitignore index 66f9c0d..9008c00 100644 --- a/.gitignore +++ b/.gitignore @@ -131,5 +131,7 @@ dmypy.json # config, quick test config.toml quick.py +tools/* +!tools/README.md .vscode/ \ No newline at end of file diff --git a/README.md b/README.md index 1475eee..296a6f5 100644 --- a/README.md +++ b/README.md @@ -339,14 +339,14 @@ print(mixer.query('/ch/01/mix/on')) ### `Tests` -Unplug any expensive equipment before running tests. -Save your current settings to a snapshot first. +Install [poetry](https://python-poetry.org/docs/#installation) and then: -First make sure you installed the [development dependencies](https://github.com/onyx-and-iris/xair-api-python#installation) +```powershell +poetry poe test-xair +poetry poe test-x32 +``` -To run all tests: - -`pytest -v`. +Unplug any expensive equipment and save your current settings to a snapshot first. ## License diff --git a/pyproject.toml b/pyproject.toml index 950de50..375b91e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,29 +31,33 @@ build-backend = "poetry.core.masonry.api" obs.script = "scripts:ex_obs" sends.script = "scripts:ex_sends" headamp.script = "scripts:ex_headamp" -xair.script = "scripts:test_xair" -x32.script = "scripts:test_x32" -all.script = "scripts:test_all" +test-xair.script = "scripts:test_xair" +test-x32.script = "scripts:test_x32" +test-all.script = "scripts:test_all" [tool.tox] legacy_tox_ini = """ -[tox] -envlist = py310,py311,py312 + [tox] + envlist = py310,py311,py312,py313 -[testenv] -setenv = VIRTUALENV_DISCOVERY=pyenv -allowlist_externals = poetry -commands = - poetry install -v - poetry run pytest tests/ + [testenv] + passenv = + TEST_MODULE + setenv = VIRTUALENV_DISCOVERY=pyenv + allowlist_externals = poetry + commands_pre = + poetry install --no-interaction --no-root + commands = + poetry run pytest tests/{env:TEST_MODULE} -[testenv:obs] -setenv = VIRTUALENV_DISCOVERY=pyenv -allowlist_externals = poetry -deps = obsws-python -commands = - poetry install -v --without dev - poetry run python examples/xair_obs/ + [testenv:obs] + setenv = VIRTUALENV_DISCOVERY=pyenv + allowlist_externals = poetry + deps = obsws-python + commands_pre = + poetry install --no-interaction --no-root --without dev + commands = + poetry run python examples/xair_obs """ [tool.ruff] diff --git a/scripts.py b/scripts.py index 9c8d006..20eb57d 100644 --- a/scripts.py +++ b/scripts.py @@ -1,31 +1,35 @@ +import os import subprocess import sys from pathlib import Path def ex_obs(): - subprocess.run(["tox", "r", "-e", "obs"]) + subprocess.run(['tox', 'r', '-e', 'obs']) def ex_sends(): - path = Path.cwd() / "examples" / "sends" / "." + path = Path.cwd() / 'examples' / 'sends' / '.' subprocess.run([sys.executable, str(path)]) def ex_headamp(): - path = Path.cwd() / "examples" / "headamp" / "." + path = Path.cwd() / 'examples' / 'headamp' / '.' subprocess.run([sys.executable, str(path)]) def test_xair(): - path = Path.cwd() / "tests" / "xair" - subprocess.run(["pytest", "-v", str(path)]) + subprocess.run(['tox'], env=os.environ.copy() | {'TEST_MODULE': 'xair'}) def test_x32(): - path = Path.cwd() / "tests" / "x32" - subprocess.run(["pytest", "-v", str(path)]) + path = Path.cwd() / 'tools' / 'x32.exe' + proc = subprocess.Popen([str(path), '-i', 'x32.local']) + subprocess.run(['tox'], env=os.environ.copy() | {'TEST_MODULE': 'x32'}) + proc.terminate() def test_all(): - subprocess.run(["tox"]) + steps = [test_xair, test_x32] + for step in steps: + step() diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..150eae3 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,3 @@ +# X32 Tests + +Download the [x32 Emulator](https://sites.google.com/site/patrickmaillot/x32#h.p_rE4IH0Luimc0) and place it in this directory in order to run the x32 tests. \ No newline at end of file