Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3e4781a

Browse files
Liora Milbaumnejch
Liora Milbaum
authored andcommitted
refactor: pytest-docker fixtures
1 parent124abab commit3e4781a

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

‎tests/functional/conftest.py‎

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
importgitlab
1313
importgitlab.base
1414
fromtests.functionalimporthelpers
15+
fromtests.functional.fixtures.dockerimport*# noqa
1516

1617
SLEEP_TIME=10
1718

@@ -34,11 +35,6 @@ def gitlab_version(gl) -> GitlabVersion:
3435
returnGitlabVersion(major=major,minor=minor,patch=patch,revision=revision)
3536

3637

37-
@pytest.fixture(scope="session")
38-
defdocker_compose_command():
39-
return"docker compose"
40-
41-
4238
@pytest.fixture(scope="session")
4339
deffixture_dir(test_dir)->pathlib.Path:
4440
returntest_dir/"functional"/"fixtures"
@@ -160,26 +156,6 @@ def temp_dir() -> pathlib.Path:
160156
returnpathlib.Path(tempfile.gettempdir())
161157

162158

163-
@pytest.fixture(scope="session")
164-
defdocker_compose_file(fixture_dir):
165-
returnfixture_dir/"docker-compose.yml"
166-
167-
168-
@pytest.fixture(scope="session")
169-
defdocker_compose_project_name():
170-
"""Set a consistent project name to enable optional reuse of containers."""
171-
return"pytest-python-gitlab"
172-
173-
174-
@pytest.fixture(scope="session")
175-
defdocker_cleanup(request):
176-
"""Conditionally keep containers around by overriding the cleanup command."""
177-
ifrequest.config.getoption("--keep-containers"):
178-
# Print version and exit.
179-
return"-v"
180-
return"down -v"
181-
182-
183159
@pytest.fixture(scope="session")
184160
defcheck_is_alive():
185161
"""

‎tests/functional/fixtures/__init__.py‎

Whitespace-only changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
pytest-docker fixture overrides.
3+
See https://github.com/avast/pytest-docker#available-fixtures.
4+
"""
5+
importpytest
6+
7+
8+
@pytest.fixture(scope="session")
9+
defdocker_compose_command():
10+
return"docker compose"
11+
12+
13+
@pytest.fixture(scope="session")
14+
defdocker_compose_project_name():
15+
"""Set a consistent project name to enable optional reuse of containers."""
16+
return"pytest-python-gitlab"
17+
18+
19+
@pytest.fixture(scope="session")
20+
defdocker_compose_file(fixture_dir):
21+
returnfixture_dir/"docker-compose.yml"
22+
23+
24+
@pytest.fixture(scope="session")
25+
defdocker_cleanup(request):
26+
"""Conditionally keep containers around by overriding the cleanup command."""
27+
ifrequest.config.getoption("--keep-containers"):
28+
# Print version and exit.
29+
return"-v"
30+
return"down -v"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp