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

Commit196538b

Browse files
JohnVillalovosnejch
authored andcommitted
chore: simplifywait_for_sidekiq usage
Simplify usage of `wait_for_sidekiq` by putting the assert if it timedout inside the function rather than after calling it.
1 parent6627a60 commit196538b

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

‎tests/functional/api/test_lazy_objects.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def test_save_after_lazy_get_with_path(project, lazy_project):
2929

3030
deftest_delete_after_lazy_get_with_path(gl,group,wait_for_sidekiq):
3131
project=gl.projects.create({"name":"lazy_project","namespace_id":group.id})
32-
result=wait_for_sidekiq(timeout=60)
33-
assertresultisTrue,"sidekiq process should have terminated but did not"
32+
wait_for_sidekiq(timeout=60)
3433
lazy_project=gl.projects.get(project.path_with_namespace,lazy=True)
3534
lazy_project.delete()
3635

‎tests/functional/api/test_merge_requests.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ def test_merge_request_should_remove_source_branch(
150150

151151
mr.merge(should_remove_source_branch=True)
152152

153-
result=wait_for_sidekiq(timeout=60)
154-
assertresultisTrue,"sidekiq process should have terminated but did not"
153+
wait_for_sidekiq(timeout=60)
155154

156155
# Wait until it is merged
157156
mr_iid=mr.iid
@@ -162,8 +161,7 @@ def test_merge_request_should_remove_source_branch(
162161
time.sleep(0.5)
163162
assertmr.merged_atisnotNone
164163
time.sleep(0.5)
165-
result=wait_for_sidekiq(timeout=60)
166-
assertresultisTrue,"sidekiq process should have terminated but did not"
164+
wait_for_sidekiq(timeout=60)
167165

168166
# Ensure we can NOT get the MR branch
169167
withpytest.raises(gitlab.exceptions.GitlabGetError):
@@ -195,8 +193,7 @@ def test_merge_request_large_commit_message(
195193
merge_commit_message=merge_commit_message,should_remove_source_branch=False
196194
)
197195

198-
result=wait_for_sidekiq(timeout=60)
199-
assertresultisTrue,"sidekiq process should have terminated but did not"
196+
wait_for_sidekiq(timeout=60)
200197

201198
# Wait until it is merged
202199
mr_iid=mr.iid
@@ -235,8 +232,7 @@ def test_merge_request_merge_ref_should_fail(
235232
"commit_message":"Another commit in main branch",
236233
}
237234
)
238-
result=wait_for_sidekiq(timeout=60)
239-
assertresultisTrue,"sidekiq process should have terminated but did not"
235+
wait_for_sidekiq(timeout=60)
240236

241237
# Check for non-existing merge_ref for MR with conflicts
242238
withpytest.raises(gitlab.exceptions.GitlabGetError):

‎tests/functional/api/test_users.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ def test_delete_user(gl, wait_for_sidekiq):
7070
)
7171

7272
new_user.delete()
73-
result=wait_for_sidekiq(timeout=60)
74-
assertresultisTrue,"sidekiq process should have terminated but did not"
73+
wait_for_sidekiq(timeout=60)
7574

7675
assertnew_user.idnotin [user.idforuseringl.users.list()]
7776

‎tests/functional/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def wait_for_sidekiq(gl):
224224
Use this with asserts for slow tasks (group/project/user creation/deletion).
225225
"""
226226

227-
def_wait(timeout=30,step=0.5):
227+
def_wait(timeout:int=30,step:float=0.5,allow_fail:bool=False)->bool:
228228
forcountinrange(timeout):
229229
time.sleep(step)
230230
busy=False
@@ -235,6 +235,7 @@ def _wait(timeout=30, step=0.5):
235235
ifnotbusy:
236236
returnTrue
237237
logging.info(f"sidekiq busy{count} of{timeout}")
238+
assertallow_fail,"sidekiq process should have terminated but did not."
238239
returnFalse
239240

240241
return_wait

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp