tj.git-extras/tests/conftest.py
oikarinen 2f4b57d52b
Some checks are pending
ci / lint (push) Waiting to run
ci / typo (push) Waiting to run
ci / test (push) Waiting to run
ci / build (macos-latest) (push) Waiting to run
ci / build (ubuntu-latest) (push) Waiting to run
feat: add git-continue (#1176)
* feat: add git-continue

Also refactor `git-abort` to parse action from the called file name.

There's a promise for this in #865 but that was a long time ago.

* fix: add git-continue

address review comments, fix the script, remove unnecessary testpath
import.
2024-11-28 16:50:29 +08:00

46 lines
1.1 KiB
Python

# Sharing fixtures
# Ref: https://docs.pytest.org/en/6.2.x/fixture.html#scope-sharing-fixtures-across-classes-modules-packages-or-session
import pytest
from helper import TempRepository
def create_repo(dirname=None):
repo = TempRepository(dirname)
repo.create_tmp_file() # tmp_file_a
repo.create_tmp_file() # tmp_file_b
repo.switch_cwd_under_repo()
return repo
def init_repo_git_status(repo):
git = repo.get_repo_git()
git.add(".")
git.config("--local", "user.name", "test")
git.config("--local", "user.email", "test@git-extras.com")
git.commit("-m", "chore: initial commit")
@pytest.fixture(scope="module")
def temp_repo():
repo = create_repo()
init_repo_git_status(repo)
return repo
@pytest.fixture(scope="module")
def named_temp_repo(request):
dirname = request.param
repo = create_repo(dirname)
init_repo_git_status(repo)
yield repo
repo.teardown()
@pytest.fixture(scope="function")
def temp_repo_clean():
"""Create a temporary repository that is reset for each function call."""
repo = create_repo()
init_repo_git_status(repo)
return repo