Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quick test command #344

Merged
merged 4 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ poetry run poe test_all
```
for successful execution of this command `Docker` and `docker compose` are required.

To do a quick sanity check without the need to up docker containers or wait for long tests, run
```bash
poetry run poe quick_test
```

_There's also quick_test_coverage for quick htmlcov generation, though it is very likely to be incomplete due to deselection of some tests_
RLKRo marked this conversation as resolved.
Show resolved Hide resolved

To make sure that the code satisfies only the style requirements, run
```bash
poetry run poe lint
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ lint.ignore_fail = "return_non_zero"
format = "scripts.codestyle:_run_black(modify=True)"
clean_docs = "scripts.clean:clean_docs"
clean = "scripts.clean:clean"
quick_test = "scripts.test:quick_test"
quick_test_coverage = "scripts.test:quick_test_coverage"
test_no_cov = "scripts.test:test_no_cov"
test_no_deps = "scripts.test:test_no_deps"
test_all = "scripts.test:test_all"
Expand Down
23 changes: 22 additions & 1 deletion scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .utils import docker_client


def _test(coverage: bool, dependencies: bool) -> int:
def _test(coverage: bool = False, dependencies: bool = False, quick: bool = False) -> int:
"""
Run framework tests, located in `tests/` dir, using env defined in `.env_file`.
Please keep in mind that:
Expand All @@ -16,12 +16,25 @@ def _test(coverage: bool, dependencies: bool) -> int:
2. Enabling dependencies is effectively same as enabling docker
(docker containers **should** be running in that case).
3. Coverage requires all dependencies and docker (will have no effect otherwise).

:param coverage: Enable coverage calculation
:param dependencies: Disallow skipping tests
:param quick: Deselect 'slow' and 'docker' marked tests
"""
test_coverage_threshold = 90

dotenv.load_dotenv(".env_file")
args = ["tests/"]

if quick:
args = [
"-m",
"not docker",
"-m",
"not slow",
*args,
]

if dependencies and coverage:
args = [
"-m",
Expand Down Expand Up @@ -67,6 +80,14 @@ def _test(coverage: bool, dependencies: bool) -> int:
return pytest.main(args)


def quick_test():
exit(_test(quick=True))


def quick_test_coverage():
exit(_test(coverage=True, quick=True))


@docker_client
def test_no_cov(docker: Optional[DockerClient]):
result = _test(False, docker is not None)
Expand Down
Loading