Skip to content

Commit

Permalink
tests: Add shim for str.removesuffix on Py3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
nbraud committed Nov 22, 2023
1 parent 5d7472c commit a175102
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import shutil
import sys
from pathlib import Path

import pytest

from helpers import chdir, check_run


if sys.version_info >= (3, 9):
removesuffix = str.removesuffix
else:
def removesuffix(s: str, suffix: str) -> str:
if not s.endswith(suffix):
return s
return s[:-len(suffix)]


def _src_name(src):
if isinstance(src, Path):
return src.name

return src.rsplit('/', 1)[1].removesuffix('.git')
return removesuffix(src, '.git').rsplit('/', 1)[1]


@pytest.fixture(scope="session", ids=_src_name, params=(
Expand Down

0 comments on commit a175102

Please sign in to comment.