Skip to content

Commit 5414694

Browse files
committed
fix(tests): exclude new pytest-gitlab plugin when running tests via tox
The previous commit adds a new pytest plugin `pytest-gitlab` but does not (yet) update the existing tests to use it. For now it needs to explicitly be disabled when running tests so it does not interfere with the original fixtures. Since tox now runs the tests with `-p no:gitlab` the test_gitflab_plugin_is_loaded test will always fail. Skip it for now and instead ensure the entrypoint is at least there. Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
1 parent 0f114d5 commit 5414694

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

requirements-docker.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
-r requirements.txt
22
-r requirements-test.txt
3-
pytest-docker==3.2.5

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pytest-console-scripts==1.4.1
66
pytest-cov==7.0.0
77
pytest-github-actions-annotate-failures==0.3.0
88
pytest==9.0.2
9+
pytest-docker==3.2.5
910
PyYaml==6.0.3
1011
responses==0.25.8
1112
respx==0.22.0

tests/unit/test_pytest_plugin.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
"""Tests for the gitlab pytest plugin."""
1+
"""Tests for the pytest-gitlab plugin."""
22

3+
from importlib.metadata import entry_points
34

4-
def test_gitlab_plugin_is_registered(request):
5-
"""'gitlab' is a registered pytest plugin."""
5+
import pytest
6+
7+
8+
@pytest.mark.skip(reason="pytest-gitlab plugin is disabled in tox")
9+
def test_gitlab_plugin_is_loaded(request):
10+
"""'gitlab' is a loaded pytest plugin."""
611
assert request.config.pluginmanager.hasplugin("gitlab")
12+
13+
14+
def test_gitlab_plugin_is_registered():
15+
"""'gitlab' is registered as a pytest11 entry point."""
16+
pytest11_entry_points = entry_points(group="pytest11")
17+
assert any(ep.value == "gitlab.testing.plugin" for ep in pytest11_entry_points)

tox.ini

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ passenv =
2626
NO_COLOR
2727
PWD
2828
PY_COLORS
29-
setenv =
29+
setenv =
3030
DOCS_SOURCE = docs
3131
DOCS_BUILD = build/sphinx/html
3232
VIRTUAL_ENV={envdir}
@@ -38,7 +38,7 @@ isolated_build = True
3838
deps = -r{toxinidir}/requirements.txt
3939
-r{toxinidir}/requirements-test.txt
4040
commands =
41-
pytest tests/unit {posargs}
41+
pytest -p no:gitlab tests/unit {posargs}
4242

4343
[testenv:black]
4444
basepython = python3
@@ -102,12 +102,12 @@ per-file-ignores =
102102
gitlab/v4/objects/__init__.py:F401,F403
103103

104104
[testenv:docs]
105-
description = Builds the docs site. Generated HTML files will be available in '{env:DOCS_BUILD}'.
105+
description = Builds the docs site. Generated HTML files will be available in '{env:DOCS_BUILD}'.
106106
deps = -r{toxinidir}/requirements-docs.txt
107107
commands = sphinx-build -n -W --keep-going -b html {env:DOCS_SOURCE} {env:DOCS_BUILD}
108108

109109
[testenv:docs-serve]
110-
description =
110+
description =
111111
Builds and serves the HTML docs site locally. \
112112
Use this for verifying updates to docs. \
113113
Changes to docs files will be automatically rebuilt and served.
@@ -116,7 +116,7 @@ commands = sphinx-autobuild {env:DOCS_SOURCE} {env:DOCS_BUILD} --open-browser --
116116

117117
[testenv:cover]
118118
commands =
119-
pytest --cov --cov-report term --cov-report html \
119+
pytest -p no:gitlab --cov --cov-report term --cov-report html \
120120
--cov-report xml tests/unit {posargs}
121121

122122
[coverage:run]
@@ -133,16 +133,16 @@ exclude_lines =
133133
[testenv:cli_func_v4]
134134
deps = -r{toxinidir}/requirements-docker.txt
135135
commands =
136-
pytest --script-launch-mode=subprocess --cov --cov-report xml tests/functional/cli {posargs}
136+
pytest -p no:gitlab --script-launch-mode=subprocess --cov --cov-report xml tests/functional/cli {posargs}
137137

138138
[testenv:api_func_v4]
139139
deps = -r{toxinidir}/requirements-docker.txt
140140
commands =
141-
pytest --cov --cov-report xml tests/functional/api {posargs}
141+
pytest -p no:gitlab --cov --cov-report xml tests/functional/api {posargs}
142142

143143
[testenv:smoke]
144144
deps = -r{toxinidir}/requirements-test.txt
145-
commands = pytest tests/smoke {posargs}
145+
commands = pytest -p no:gitlab tests/smoke {posargs}
146146

147147
[testenv:pre-commit]
148148
skip_install = true
@@ -153,4 +153,4 @@ commands = pre-commit run --all-files --show-diff-on-failure
153153
skip_install = true
154154
deps = -r{toxinidir}/requirements.txt
155155
-r{toxinidir}/requirements-test.txt
156-
commands = pytest tests/install
156+
commands = pytest -p no:gitlab tests/install

0 commit comments

Comments
 (0)