Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Unit Tests

on:
push:
branches:
- "main"
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # For releases, e.g. v1.2.0
- "v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z0-9]+" # For prereleases, e.g. v1.3.0-alpha1
pull_request:
types: [opened, synchronize, reopened]

jobs:
pytest:
name: Pytest Unit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libmpv-dev mpv

- name: Install dependencies
run: |
python -m pip install --upgrade pip
./script/setup --dev

- name: Run unit tests
run: ./script/tests
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ Auto-fix formatting issues (Black + isort):
### Testing

Run the test suite:

```sh
./script/test
``` sh
./script/tests
```

## License
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dev = [
"pytest",
"isort",
"autopep8",
"pytest-asyncio",
]

[project.scripts]
Expand Down Expand Up @@ -131,3 +132,7 @@ max-args = 50

[tool.pylint.format]
expected-line-ending-format = "LF"

[tool.pytest.ini_options]
testpaths = ["tests"]
asyncio_mode = "auto"
10 changes: 7 additions & 3 deletions script/test → script/tests
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/usr/bin/env python3
import subprocess
import sys
import venv
from pathlib import Path
import sys

_DIR = Path(__file__).parent
_PROGRAM_DIR = _DIR.parent
_VENV_DIR = _PROGRAM_DIR / ".venv"
_TEST_DIR = _PROGRAM_DIR / "tests"
_TESTS_DIR = _PROGRAM_DIR / "tests" / "unit"

_TEST_DIRS = [_TESTS_DIR]

if _VENV_DIR.exists():
context = venv.EnvBuilder().ensure_directories(_VENV_DIR)
python_exe = context.env_exe
else:
python_exe = "python3"

subprocess.check_call([python_exe, "-m", "pytest", _TEST_DIR] + sys.argv[1:])

subprocess.check_call([python_exe, "-m", "pytest"] + _TEST_DIRS)

Empty file added tests/__init__.py
Empty file.
3 changes: 2 additions & 1 deletion tests/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Automated testing

tbd
From the root of LVA run:-
```./script/tests```


# Manual testing
Expand Down
Empty file added tests/unit/__init__.py
Empty file.
Loading
Loading