Skip to content

Commit d6e3325

Browse files
committed
chore: run unittest2pytest on all unit tests
1 parent 906563c commit d6e3325

File tree

12 files changed

+446
-439
lines changed

12 files changed

+446
-439
lines changed

gitlab/tests/objects/test_application.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ def resp_update_appearance(url, request):
8080

8181
with HTTMock(resp_get_appearance), HTTMock(resp_update_appearance):
8282
appearance = self.gl.appearance.get()
83-
self.assertEqual(appearance.title, self.title)
84-
self.assertEqual(appearance.description, self.description)
83+
assert appearance.title == self.title
84+
assert appearance.description == self.description
8585
appearance.title = self.new_title
8686
appearance.description = self.new_description
8787
appearance.save()
88-
self.assertEqual(appearance.title, self.new_title)
89-
self.assertEqual(appearance.description, self.new_description)
88+
assert appearance.title == self.new_title
89+
assert appearance.description == self.new_description
9090

9191
def test_update_appearance(self):
9292
@urlmatch(

gitlab/tests/objects/test_commits.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class TestCommit(TestProject):
7878
@with_httmock(resp_get_commit)
7979
def test_get_commit(self):
8080
commit = self.project.commits.get("6b2257ea")
81-
self.assertEqual(commit.short_id, "6b2257ea")
82-
self.assertEqual(commit.title, "Initial commit")
81+
assert commit.short_id == "6b2257ea"
82+
assert commit.title == "Initial commit"
8383

8484
@with_httmock(resp_create_commit)
8585
def test_create_commit(self):
@@ -89,19 +89,19 @@ def test_create_commit(self):
8989
"actions": [{"action": "create", "file_path": "README", "content": "",}],
9090
}
9191
commit = self.project.commits.create(data)
92-
self.assertEqual(commit.short_id, "ed899a2f")
93-
self.assertEqual(commit.title, data["commit_message"])
92+
assert commit.short_id == "ed899a2f"
93+
assert commit.title == data["commit_message"]
9494

9595
@with_httmock(resp_revert_commit)
9696
def test_revert_commit(self):
9797
commit = self.project.commits.get("6b2257ea", lazy=True)
9898
revert_commit = commit.revert(branch="master")
99-
self.assertEqual(revert_commit["short_id"], "8b090c1b")
100-
self.assertEqual(revert_commit["title"], 'Revert "Initial commit"')
99+
assert revert_commit["short_id"] == "8b090c1b"
100+
assert revert_commit["title"] == 'Revert "Initial commit"'
101101

102102
@with_httmock(resp_get_commit_gpg_signature)
103103
def test_get_commit_gpg_signature(self):
104104
commit = self.project.commits.get("6b2257ea", lazy=True)
105105
signature = commit.signature()
106-
self.assertEqual(signature["gpg_key_primary_keyid"], "8254AAB3FBD54AC9")
107-
self.assertEqual(signature["verification_status"], "verified")
106+
assert signature["gpg_key_primary_keyid"] == "8254AAB3FBD54AC9"
107+
assert signature["verification_status"] == "verified"

gitlab/tests/objects/test_groups.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ def setUp(self):
4848
@with_httmock(resp_get_group)
4949
def test_get_group(self):
5050
data = self.gl.groups.get(1)
51-
self.assertIsInstance(data, gitlab.v4.objects.Group)
52-
self.assertEqual(data.name, "name")
53-
self.assertEqual(data.path, "path")
54-
self.assertEqual(data.id, 1)
51+
assert isinstance(data, gitlab.v4.objects.Group)
52+
assert data.name == "name"
53+
assert data.path == "path"
54+
assert data.id == 1
5555

5656
@with_httmock(resp_create_group)
5757
def test_create_group(self):
5858
name, path = "name", "path"
5959
data = self.gl.groups.create({"name": name, "path": path})
60-
self.assertIsInstance(data, gitlab.v4.objects.Group)
61-
self.assertEqual(data.name, name)
62-
self.assertEqual(data.path, path)
60+
assert isinstance(data, gitlab.v4.objects.Group)
61+
assert data.name == name
62+
assert data.path == path
6363

6464

6565
class TestGroupExport(TestGroup):
@@ -70,32 +70,32 @@ def setUp(self):
7070
@with_httmock(resp_create_export)
7171
def test_create_group_export(self):
7272
export = self.group.exports.create()
73-
self.assertEqual(export.message, "202 Accepted")
73+
assert export.message == "202 Accepted"
7474

7575
@unittest.skip("GitLab API endpoint not implemented")
7676
@with_httmock(resp_create_export)
7777
def test_refresh_group_export_status(self):
7878
export = self.group.exports.create()
7979
export.refresh()
80-
self.assertEqual(export.export_status, "finished")
80+
assert export.export_status == "finished"
8181

8282
@with_httmock(resp_create_export, resp_download_export)
8383
def test_download_group_export(self):
8484
export = self.group.exports.create()
8585
download = export.download()
86-
self.assertIsInstance(download, bytes)
87-
self.assertEqual(download, binary_content)
86+
assert isinstance(download, bytes)
87+
assert download == binary_content
8888

8989

9090
class TestGroupImport(TestGroup):
9191
@with_httmock(resp_create_import)
9292
def test_import_group(self):
9393
group_import = self.gl.groups.import_group("file", "api-group", "API Group")
94-
self.assertEqual(group_import["message"], "202 Accepted")
94+
assert group_import["message"] == "202 Accepted"
9595

9696
@unittest.skip("GitLab API endpoint not implemented")
9797
@with_httmock(resp_create_import)
9898
def test_refresh_group_import_status(self):
9999
group_import = self.group.imports.get()
100100
group_import.refresh()
101-
self.assertEqual(group_import.import_status, "finished")
101+
assert group_import.import_status == "finished"

gitlab/tests/objects/test_projects.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ def resp_list_snippet(url, request):
296296

297297
with HTTMock(resp_list_snippet):
298298
snippets = self.project.snippets.list()
299-
self.assertEqual(len(snippets), 1)
300-
self.assertEqual(snippets[0].title, title)
301-
self.assertEqual(snippets[0].visibility, visibility)
299+
assert len(snippets) == 1
300+
assert snippets[0].title == title
301+
assert snippets[0].visibility == visibility
302302

303303
def test_get_project_snippets(self):
304304
title = "Example Snippet Title"
@@ -325,8 +325,8 @@ def resp_get_snippet(url, request):
325325

326326
with HTTMock(resp_get_snippet):
327327
snippet = self.project.snippets.get(1)
328-
self.assertEqual(snippet.title, title)
329-
self.assertEqual(snippet.visibility, visibility)
328+
assert snippet.title == title
329+
assert snippet.visibility == visibility
330330

331331
def test_create_update_project_snippets(self):
332332
title = "Example Snippet Title"
@@ -379,104 +379,104 @@ def resp_create_snippet(url, request):
379379
"visibility": visibility,
380380
}
381381
)
382-
self.assertEqual(snippet.title, title)
383-
self.assertEqual(snippet.visibility, visibility)
382+
assert snippet.title == title
383+
assert snippet.visibility == visibility
384384
title = "new-title"
385385
snippet.title = title
386386
snippet.save()
387-
self.assertEqual(snippet.title, title)
388-
self.assertEqual(snippet.visibility, visibility)
387+
assert snippet.title == title
388+
assert snippet.visibility == visibility
389389

390390

391391
class TestProjectExport(TestProject):
392392
@with_httmock(resp_create_export)
393393
def test_create_project_export(self):
394394
export = self.project.exports.create()
395-
self.assertEqual(export.message, "202 Accepted")
395+
assert export.message == "202 Accepted"
396396

397397
@with_httmock(resp_create_export, resp_export_status)
398398
def test_refresh_project_export_status(self):
399399
export = self.project.exports.create()
400400
export.refresh()
401-
self.assertEqual(export.export_status, "finished")
401+
assert export.export_status == "finished"
402402

403403
@with_httmock(resp_create_export, resp_download_export)
404404
def test_download_project_export(self):
405405
export = self.project.exports.create()
406406
download = export.download()
407-
self.assertIsInstance(download, bytes)
408-
self.assertEqual(download, binary_content)
407+
assert isinstance(download, bytes)
408+
assert download == binary_content
409409

410410

411411
class TestProjectImport(TestProject):
412412
@with_httmock(resp_import_project)
413413
def test_import_project(self):
414414
project_import = self.gl.projects.import_project("file", "api-project")
415-
self.assertEqual(project_import["import_status"], "scheduled")
415+
assert project_import["import_status"] == "scheduled"
416416

417417
@with_httmock(resp_import_status)
418418
def test_refresh_project_import_status(self):
419419
project_import = self.project.imports.get()
420420
project_import.refresh()
421-
self.assertEqual(project_import.import_status, "finished")
421+
assert project_import.import_status == "finished"
422422

423423
@with_httmock(resp_import_github)
424424
def test_import_github(self):
425425
base_path = "/root"
426426
name = "my-repo"
427427
ret = self.gl.projects.import_github("githubkey", 1234, base_path, name)
428-
self.assertIsInstance(ret, dict)
429-
self.assertEqual(ret["name"], name)
430-
self.assertEqual(ret["full_path"], "/".join((base_path, name)))
431-
self.assertTrue(ret["full_name"].endswith(name))
428+
assert isinstance(ret, dict)
429+
assert ret["name"] == name
430+
assert ret["full_path"] == "/".join((base_path, name))
431+
assert ret["full_name"].endswith(name)
432432

433433

434434
class TestProjectRemoteMirrors(TestProject):
435435
@with_httmock(resp_get_remote_mirrors)
436436
def test_list_project_remote_mirrors(self):
437437
mirrors = self.project.remote_mirrors.list()
438-
self.assertIsInstance(mirrors, list)
439-
self.assertIsInstance(mirrors[0], ProjectRemoteMirror)
440-
self.assertTrue(mirrors[0].enabled)
438+
assert isinstance(mirrors, list)
439+
assert isinstance(mirrors[0], ProjectRemoteMirror)
440+
assert mirrors[0].enabled
441441

442442
@with_httmock(resp_create_remote_mirror)
443443
def test_create_project_remote_mirror(self):
444444
mirror = self.project.remote_mirrors.create({"url": "https://example.com"})
445-
self.assertIsInstance(mirror, ProjectRemoteMirror)
446-
self.assertEqual(mirror.update_status, "none")
445+
assert isinstance(mirror, ProjectRemoteMirror)
446+
assert mirror.update_status == "none"
447447

448448
@with_httmock(resp_create_remote_mirror, resp_update_remote_mirror)
449449
def test_update_project_remote_mirror(self):
450450
mirror = self.project.remote_mirrors.create({"url": "https://example.com"})
451451
mirror.only_protected_branches = True
452452
mirror.save()
453-
self.assertEqual(mirror.update_status, "finished")
454-
self.assertTrue(mirror.only_protected_branches)
453+
assert mirror.update_status == "finished"
454+
assert mirror.only_protected_branches
455455

456456

457457
class TestProjectServices(TestProject):
458458
@with_httmock(resp_get_active_services)
459459
def test_list_active_services(self):
460460
services = self.project.services.list()
461-
self.assertIsInstance(services, list)
462-
self.assertIsInstance(services[0], ProjectService)
463-
self.assertTrue(services[0].active)
464-
self.assertTrue(services[0].push_events)
461+
assert isinstance(services, list)
462+
assert isinstance(services[0], ProjectService)
463+
assert services[0].active
464+
assert services[0].push_events
465465

466466
def test_list_available_services(self):
467467
services = self.project.services.available()
468-
self.assertIsInstance(services, list)
469-
self.assertIsInstance(services[0], str)
468+
assert isinstance(services, list)
469+
assert isinstance(services[0], str)
470470

471471
@with_httmock(resp_get_service)
472472
def test_get_service(self):
473473
service = self.project.services.get("pipelines-email")
474-
self.assertIsInstance(service, ProjectService)
475-
self.assertEqual(service.push_events, True)
474+
assert isinstance(service, ProjectService)
475+
assert service.push_events == True
476476

477477
@with_httmock(resp_get_service, resp_update_service)
478478
def test_update_service(self):
479479
service = self.project.services.get("pipelines-email")
480480
service.issues_events = True
481481
service.save()
482-
self.assertEqual(service.issues_events, True)
482+
assert service.issues_events == True

0 commit comments

Comments
 (0)