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

Commit43c2dda

Browse files
nejchJohnVillalovos
authored andcommitted
test(functional): do not require config file
1 parent5f8b8f5 commit43c2dda

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

‎tests/functional/api/test_gitlab.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ def get_all_kwargs(request):
1515
returnrequest.param
1616

1717

18-
deftest_auth_from_config(gl,temp_dir):
18+
deftest_auth_from_config(gl,gitlab_config,temp_dir):
1919
"""Test token authentication from config file"""
20-
test_gitlab=gitlab.Gitlab.from_config(
21-
config_files=[temp_dir/"python-gitlab.cfg"]
22-
)
20+
test_gitlab=gitlab.Gitlab.from_config(config_files=[gitlab_config])
2321
test_gitlab.auth()
2422
assertisinstance(test_gitlab.user,gitlab.v4.objects.CurrentUser)
2523

‎tests/functional/conftest.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,13 @@ def _wait(timeout: int = 30, step: float = 0.5, allow_fail: bool = False) -> boo
236236

237237

238238
@pytest.fixture(scope="session")
239-
defgitlab_config(
239+
defgitlab_token(
240240
check_is_alive,
241241
gitlab_container_name:str,
242242
gitlab_url:str,
243243
docker_services,
244-
temp_dir:pathlib.Path,
245244
fixture_dir:pathlib.Path,
246-
):
247-
config_file=temp_dir/"python-gitlab.cfg"
245+
)->str:
248246

249247
start_time=time.perf_counter()
250248
logging.info("Waiting for GitLab container to become ready.")
@@ -263,15 +261,20 @@ def gitlab_config(
263261
f"GitLab container is now ready after{minutes} minute(s),{seconds} seconds"
264262
)
265263

266-
token=set_token(gitlab_container_name,fixture_dir=fixture_dir)
264+
returnset_token(gitlab_container_name,fixture_dir=fixture_dir)
265+
266+
267+
@pytest.fixture(scope="session")
268+
defgitlab_config(gitlab_url:str,gitlab_token:str,temp_dir:pathlib.Path):
269+
config_file=temp_dir/"python-gitlab.cfg"
267270

268271
config=f"""[global]
269272
default = local
270273
timeout = 60
271274
272275
[local]
273276
url ={gitlab_url}
274-
private_token ={token}
277+
private_token ={gitlab_token}
275278
api_version = 4"""
276279

277280
withopen(config_file,"w",encoding="utf-8")asf:
@@ -281,11 +284,11 @@ def gitlab_config(
281284

282285

283286
@pytest.fixture(scope="session")
284-
defgl(gitlab_config):
287+
defgl(gitlab_url:str,gitlab_token:str)->gitlab.Gitlab:
285288
"""Helper instance to make fixtures and asserts directly via the API."""
286289

287290
logging.info("Instantiating python-gitlab gitlab.Gitlab instance")
288-
instance=gitlab.Gitlab.from_config("local", [gitlab_config])
291+
instance=gitlab.Gitlab(gitlab_url,private_token=gitlab_token)
289292

290293
logging.info("Reset GitLab")
291294
reset_gitlab(instance)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp