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

Commitd4ee0a6

Browse files
committed
chore: remove unnecessary random function
1 parent79489c7 commitd4ee0a6

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

‎tools/functional/conftest.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
importtime
21
importtempfile
2+
importtime
3+
importuuid
34
frompathlibimportPath
45
fromrandomimportrandint
56
fromsubprocessimportcheck_output
@@ -13,16 +14,6 @@
1314
TEST_DIR=Path(__file__).resolve().parent
1415

1516

16-
defrandom_id():
17-
"""
18-
Helper to ensure new resource creation does not clash with
19-
existing resources, for example when a previous test deleted a
20-
resource but GitLab is still deleting it asynchronously in the
21-
background. TODO: Expand to make it 100% safe.
22-
"""
23-
returnrandint(9,9999)
24-
25-
2617
defreset_gitlab(gl):
2718
# previously tools/reset_gitlab.py
2819
forprojectingl.projects.list():
@@ -125,7 +116,7 @@ def gl(gitlab_config):
125116
@pytest.fixture(scope="module")
126117
defgroup(gl):
127118
"""Group fixture for group API resource tests."""
128-
_id=random_id()
119+
_id=uuid.uuid4().hex
129120
data= {
130121
"name":f"test-group-{_id}",
131122
"path":f"group-{_id}",
@@ -143,7 +134,7 @@ def group(gl):
143134
@pytest.fixture(scope="module")
144135
defproject(gl):
145136
"""Project fixture for project API resource tests."""
146-
_id=random_id()
137+
_id=uuid.uuid4().hex
147138
name=f"test-project-{_id}"
148139

149140
project=gl.projects.create(name=name)
@@ -159,7 +150,7 @@ def project(gl):
159150
@pytest.fixture(scope="module")
160151
defuser(gl):
161152
"""User fixture for user API resource tests."""
162-
_id=random_id()
153+
_id=uuid.uuid4().hex
163154
email=f"user{_id}@email.com"
164155
username=f"user{_id}"
165156
name=f"User{_id}"
@@ -178,7 +169,7 @@ def user(gl):
178169
@pytest.fixture(scope="module")
179170
defissue(project):
180171
"""Issue fixture for issue API resource tests."""
181-
_id=random_id()
172+
_id=uuid.uuid4().hex
182173
data= {"title":f"Issue{_id}","description":f"Issue{_id} description"}
183174

184175
returnproject.issues.create(data)
@@ -187,7 +178,7 @@ def issue(project):
187178
@pytest.fixture(scope="module")
188179
deflabel(project):
189180
"""Label fixture for project label API resource tests."""
190-
_id=random_id()
181+
_id=uuid.uuid4().hex
191182
data= {
192183
"name":f"prjlabel{_id}",
193184
"description":f"prjlabel1{_id} description",
@@ -200,7 +191,7 @@ def label(project):
200191
@pytest.fixture(scope="module")
201192
defgroup_label(group):
202193
"""Label fixture for group label API resource tests."""
203-
_id=random_id()
194+
_id=uuid.uuid4().hex
204195
data= {
205196
"name":f"grplabel{_id}",
206197
"description":f"grplabel1{_id} description",
@@ -213,7 +204,7 @@ def group_label(group):
213204
@pytest.fixture(scope="module")
214205
defvariable(project):
215206
"""Variable fixture for project variable API resource tests."""
216-
_id=random_id()
207+
_id=uuid.uuid4().hex
217208
data= {"key":f"var{_id}","value":f"Variable{_id}"}
218209

219210
returnproject.variables.create(data)
@@ -222,7 +213,7 @@ def variable(project):
222213
@pytest.fixture(scope="module")
223214
defdeploy_token(project):
224215
"""Deploy token fixture for project deploy token API resource tests."""
225-
_id=random_id()
216+
_id=uuid.uuid4().hex
226217
data= {
227218
"name":f"token-{_id}",
228219
"username":"root",
@@ -236,7 +227,7 @@ def deploy_token(project):
236227
@pytest.fixture(scope="module")
237228
defgroup_deploy_token(group):
238229
"""Deploy token fixture for group deploy token API resource tests."""
239-
_id=random_id()
230+
_id=uuid.uuid4().hex
240231
data= {
241232
"name":f"group-token-{_id}",
242233
"username":"root",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp