forked from python-gitlab/python-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
57 lines (40 loc) · 1.1 KB
/
Copy pathconftest.py
File metadata and controls
57 lines (40 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import asyncio
import pytest
from gitlab import AsyncGitlab, Gitlab
@pytest.fixture(params=[Gitlab, AsyncGitlab], ids=["sync", "async"])
def gitlab_class(request):
return request.param
@pytest.fixture
def gl(gitlab_class):
return gitlab_class(
"http://localhost", private_token="private_token", api_version=4
)
async def awaiter(v):
if asyncio.iscoroutine(v):
return await v
else:
return v
async def returner(v):
return v
@pytest.fixture
def gl_get_value(gl):
"""Fixture that returns async function that either return input value or awaits it
Result function is based on client not the value of function argument,
so if we accidentally mess up with return gitlab client value, then
we will know
Usage::
result = gl.http_get()
result = await gl_get_value(result)
"""
if isinstance(gl, Gitlab):
return returner
else:
return awaiter
@pytest.fixture
def is_gl_sync(gl):
"""If gitlab client sync or not
"""
if isinstance(gl, Gitlab):
return True
else:
return False