Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gitlab/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ def get(
GitlabAuthenticationError: If authentication is not correct
GitlabGetError: If the server cannot perform the request
"""
clean_id = id
if not isinstance(id, int):
id = utils.clean_str_id(id)
path = "%s/%s" % (self.path, id)
clean_id = utils.clean_str_id(id)
path = "%s/%s" % (self.path, clean_id)
if TYPE_CHECKING:
assert self._obj_cls is not None
if lazy is True:
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/api/test_branch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import gitlab
import pytest

@pytest.mark.parametrize("lazy", [True, False])
def test_delete_branch(gl, project, branch, lazy):
b = project.branches.get(branch.name, lazy=lazy)
b.delete()
11 changes: 11 additions & 0 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ def project(gl):
except gitlab.exceptions.GitlabDeleteError as e:
print(f"Project already deleted: {e}")

@pytest.fixture(scope="function")
def branch(project):
"""Branch fixture for branch API resource tests."""
branch = project.branches.create({"branch":f"test/branch", "ref":"master"})
yield branch

try:
branch.delete()
except gitlab.exceptions.GitlabDeleteError as e:
print(f"Project already deleted: {e}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(f"Project already deleted: {e}")
print(f"Branch already deleted: {e}")



@pytest.fixture(scope="function")
def merge_request(project, wait_for_sidekiq):
Expand Down