Merge branch 'feature/10' into dev
ID: 10
Type: feature
Title: pytest current test context fixtures
Status: done
Priority: high
Created: 2025-06-20
Description: add fixtures for doing things in relation to the active testing
context
This commit is contained in:
commit
59dcc2c7c0
7 changed files with 52 additions and 3 deletions
3
Makefile
3
Makefile
|
|
@ -21,6 +21,9 @@ test-reports: test-reports/unit test-reports/static
|
||||||
test-reports/unit:
|
test-reports/unit:
|
||||||
python3 -m pipenv run -v test-unit
|
python3 -m pipenv run -v test-unit
|
||||||
|
|
||||||
|
test-reports/integration:
|
||||||
|
python3 -m pipenv run -v test-integration
|
||||||
|
|
||||||
test-reports/static:
|
test-reports/static:
|
||||||
python3 -m pipenv run -v test-static
|
python3 -m pipenv run -v test-static
|
||||||
|
|
||||||
|
|
|
||||||
1
Pipfile
1
Pipfile
|
|
@ -17,3 +17,4 @@ python_version = "3.11"
|
||||||
"build" = "python3 -m build"
|
"build" = "python3 -m build"
|
||||||
"test-static" = "tox run -m static"
|
"test-static" = "tox run -m static"
|
||||||
"test-unit" = "tox run -m unit"
|
"test-unit" = "tox run -m unit"
|
||||||
|
"test-integration" = "tox run -m integration"
|
||||||
|
|
|
||||||
2
TODO
2
TODO
|
|
@ -156,7 +156,7 @@ Description: license specification is no longer a trove classifier in
|
||||||
ID: 10
|
ID: 10
|
||||||
Type: feature
|
Type: feature
|
||||||
Title: pytest current test context fixtures
|
Title: pytest current test context fixtures
|
||||||
Status: in-progress
|
Status: done
|
||||||
Priority: high
|
Priority: high
|
||||||
Created: 2025-06-20
|
Created: 2025-06-20
|
||||||
Description: add fixtures for doing things in relation to the active testing
|
Description: add fixtures for doing things in relation to the active testing
|
||||||
|
|
|
||||||
14
src/byteb4rb1e/utils/testing/pytest/fixtures.py
Normal file
14
src/byteb4rb1e/utils/testing/pytest/fixtures.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def current_test() -> Tuple[Path, str]:
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
suite_path, case_name = os.getenv('PYTEST_CURRENT_TEST').split('::', 1)
|
||||||
|
case_name = case_name.split(' ', 1)[0]
|
||||||
|
return Path(suite_path).resolve(), case_name
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.pytest
|
||||||
|
|
||||||
|
from byteb4rb1e.utils.testing.pytest.fixtures import current_test
|
||||||
|
|
||||||
|
|
||||||
|
def test_current_test(current_test):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
suite_path, case_name = current_test
|
||||||
|
|
||||||
|
assert str(Path(__file__)) == str(suite_path)
|
||||||
|
assert case_name == "test_current_test"
|
||||||
5
tests/integration/conftest.py
Normal file
5
tests/integration/conftest.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
def pytest_configure(config):
|
||||||
|
# register an additional marker
|
||||||
|
config.addinivalue_line(
|
||||||
|
"markers", "pytest: test pytest integration"
|
||||||
|
)
|
||||||
14
tox.ini
14
tox.ini
|
|
@ -2,7 +2,8 @@
|
||||||
requires =
|
requires =
|
||||||
tox>=4.19
|
tox>=4.19
|
||||||
env_list =
|
env_list =
|
||||||
py3{8-12}-{unit}
|
unit-py3{9-13}
|
||||||
|
integration-py3{9-13}-pytest8
|
||||||
lint
|
lint
|
||||||
format
|
format
|
||||||
|
|
||||||
|
|
@ -34,7 +35,7 @@ deps =
|
||||||
commands =
|
commands =
|
||||||
black --check src tests
|
black --check src tests
|
||||||
|
|
||||||
[testenv:py3{9-13}-unit]
|
[testenv:unit-py3{9-13}]
|
||||||
description = run type check on code base
|
description = run type check on code base
|
||||||
labels = unit
|
labels = unit
|
||||||
deps =
|
deps =
|
||||||
|
|
@ -42,3 +43,12 @@ deps =
|
||||||
pytest
|
pytest
|
||||||
commands =
|
commands =
|
||||||
pytest tests/unit --junitxml=test-reports/{env_name}.xml
|
pytest tests/unit --junitxml=test-reports/{env_name}.xml
|
||||||
|
|
||||||
|
[testenv:integration-py3{9-13}-pytest8]
|
||||||
|
description = run pytest integration tests
|
||||||
|
labels = integration
|
||||||
|
deps =
|
||||||
|
{[testenv]deps}
|
||||||
|
pytest8: pytest>=8.0,<=9.0
|
||||||
|
commands =
|
||||||
|
pytest tests/integration -m pytest --junitxml=test-reports/{env_name}.xml
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue