Skip to content

Commit 11383e7

Browse files
committed
chore: run unittest2pytest on all unit tests
1 parent 402566a commit 11383e7

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
@@ -341,9 +341,9 @@ def resp_list_snippet(url, request):
341341

342342
with HTTMock(resp_list_snippet):
343343
snippets = self.project.snippets.list()
344-
self.assertEqual(len(snippets), 1)
345-
self.assertEqual(snippets[0].title, title)
346-
self.assertEqual(snippets[0].visibility, visibility)
344+
assert len(snippets) == 1
345+
assert snippets[0].title == title
346+
assert snippets[0].visibility == visibility
347347

348348
def test_get_project_snippets(self):
349349
title = "Example Snippet Title"
@@ -370,8 +370,8 @@ def resp_get_snippet(url, request):
370370

371371
with HTTMock(resp_get_snippet):
372372
snippet = self.project.snippets.get(1)
373-
self.assertEqual(snippet.title, title)
374-
self.assertEqual(snippet.visibility, visibility)
373+
assert snippet.title == title
374+
assert snippet.visibility == visibility
375375

376376
def test_create_update_project_snippets(self):
377377
title = "Example Snippet Title"
@@ -424,107 +424,107 @@ def resp_create_snippet(url, request):
424424
"visibility": visibility,
425425
}
426426
)
427-
self.assertEqual(snippet.title, title)
428-
self.assertEqual(snippet.visibility, visibility)
427+
assert snippet.title == title
428+
assert snippet.visibility == visibility
429429
title = "new-title"
430430
snippet.title = title
431431
snippet.save()
432-
self.assertEqual(snippet.title, title)
433-
self.assertEqual(snippet.visibility, visibility)
432+
assert snippet.title == title
433+
assert snippet.visibility == visibility
434434

435435

436436
class TestProjectExport(TestProject):
437437
@with_httmock(resp_create_export)
438438
def test_create_project_export(self):
439439
export = self.project.exports.create()
440-
self.assertEqual(export.message, "202 Accepted")
440+
assert export.message == "202 Accepted"
441441

442442
@with_httmock(resp_create_export, resp_export_status)
443443
def test_refresh_project_export_status(self):
444444
export = self.project.exports.create()
445445
export.refresh()
446-
self.assertEqual(export.export_status, "finished")
446+
assert export.export_status == "finished"
447447

448448
@with_httmock(resp_create_export, resp_download_export)
449449
def test_download_project_export(self):
450450
export = self.project.exports.create()
451451
download = export.download()
452-
self.assertIsInstance(download, bytes)
453-
self.assertEqual(download, binary_content)
452+
assert isinstance(download, bytes)
453+
assert download == binary_content
454454

455455

456456
class TestProjectImport(TestProject):
457457
@with_httmock(resp_import_project)
458458
def test_import_project(self):
459459
project_import = self.gl.projects.import_project("file", "api-project")
460-
self.assertEqual(project_import["import_status"], "scheduled")
460+
assert project_import["import_status"] == "scheduled"
461461

462462
@with_httmock(resp_import_status)
463463
def test_refresh_project_import_status(self):
464464
project_import = self.project.imports.get()
465465
project_import.refresh()
466-
self.assertEqual(project_import.import_status, "finished")
466+
assert project_import.import_status == "finished"
467467

468468
@with_httmock(resp_import_github)
469469
def test_import_github(self):
470470
base_path = "/root"
471471
name = "my-repo"
472472
ret = self.gl.projects.import_github("githubkey", 1234, base_path, name)
473-
self.assertIsInstance(ret, dict)
474-
self.assertEqual(ret["name"], name)
475-
self.assertEqual(ret["full_path"], "/".join((base_path, name)))
476-
self.assertTrue(ret["full_name"].endswith(name))
473+
assert isinstance(ret, dict)
474+
assert ret["name"] == name
475+
assert ret["full_path"] == "/".join((base_path, name))
476+
assert ret["full_name"].endswith(name)
477477

478478

479479
class TestProjectRemoteMirrors(TestProject):
480480
@with_httmock(resp_get_remote_mirrors)
481481
def test_list_project_remote_mirrors(self):
482482
mirrors = self.project.remote_mirrors.list()
483-
self.assertIsInstance(mirrors, list)
484-
self.assertIsInstance(mirrors[0], ProjectRemoteMirror)
485-
self.assertTrue(mirrors[0].enabled)
483+
assert isinstance(mirrors, list)
484+
assert isinstance(mirrors[0], ProjectRemoteMirror)
485+
assert mirrors[0].enabled
486486

487487
@with_httmock(resp_create_remote_mirror)
488488
def test_create_project_remote_mirror(self):
489489
mirror = self.project.remote_mirrors.create({"url": "https://example.com"})
490-
self.assertIsInstance(mirror, ProjectRemoteMirror)
491-
self.assertEqual(mirror.update_status, "none")
490+
assert isinstance(mirror, ProjectRemoteMirror)
491+
assert mirror.update_status == "none"
492492

493493
@with_httmock(resp_create_remote_mirror, resp_update_remote_mirror)
494494
def test_update_project_remote_mirror(self):
495495
mirror = self.project.remote_mirrors.create({"url": "https://example.com"})
496496
mirror.only_protected_branches = True
497497
mirror.save()
498-
self.assertEqual(mirror.update_status, "finished")
499-
self.assertTrue(mirror.only_protected_branches)
498+
assert mirror.update_status == "finished"
499+
assert mirror.only_protected_branches
500500

501501

502502
class TestProjectServices(TestProject):
503503
@with_httmock(resp_get_active_services)
504504
def test_list_active_services(self):
505505
services = self.project.services.list()
506-
self.assertIsInstance(services, list)
507-
self.assertIsInstance(services[0], ProjectService)
508-
self.assertTrue(services[0].active)
509-
self.assertTrue(services[0].push_events)
506+
assert isinstance(services, list)
507+
assert isinstance(services[0], ProjectService)
508+
assert services[0].active
509+
assert services[0].push_events
510510

511511
def test_list_available_services(self):
512512
services = self.project.services.available()
513-
self.assertIsInstance(services, list)
514-
self.assertIsInstance(services[0], str)
513+
assert isinstance(services, list)
514+
assert isinstance(services[0], str)
515515

516516
@with_httmock(resp_get_service)
517517
def test_get_service(self):
518518
service = self.project.services.get("pipelines-email")
519-
self.assertIsInstance(service, ProjectService)
520-
self.assertEqual(service.push_events, True)
519+
assert isinstance(service, ProjectService)
520+
assert service.push_events == True
521521

522522
@with_httmock(resp_get_service, resp_update_service)
523523
def test_update_service(self):
524524
service = self.project.services.get("pipelines-email")
525525
service.issues_events = True
526526
service.save()
527-
self.assertEqual(service.issues_events, True)
527+
assert service.issues_events == True
528528

529529

530530
class TestProjectPipelineSchedule(TestProject):

0 commit comments

Comments
 (0)