Skip to content

Commit

Permalink
only use tmp_path in test_conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Spitfire1900 committed Jan 1, 2025
1 parent d616bea commit 8b96eab
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions tests/test_xontrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,29 +137,30 @@ def test_clean(git_repo):
assert PromptFormatter()('{pygitstatus.clean}') == '{BOLD_GREEN}✓{RESET}'


def test_conflict(git_repo):
with cd(git_repo.working_tree_dir):
base_commit = git_repo.index.commit('initial commit')
default_branch = git_repo.active_branch.name
conflict_file = Path('conflict_file.txt')

conflict_file.write_text('Hello World!', encoding='utf-8')
git_repo.git.add(conflict_file)
git_repo.index.commit('m1')

git_repo.git.checkout(base_commit)
git_repo.create_head('f1')
git_repo.git.checkout('f1')
conflict_file.write_text('Goodbye World!', encoding='utf-8')
git_repo.git.add(conflict_file)
git_repo.index.commit('f1')

git_repo.git.checkout(default_branch)
# Should error since there is a conflict
with contextlib.suppress(GitCommandError):
git_repo.git.merge('f1')

assert PromptFormatter()('{pygitstatus.conflicts}') == '{RED}×1{RESET}'
def test_conflict(tmp_path):
os.chdir(tmp_path)
git_repo = Repo.init()
base_commit = git_repo.index.commit('initial commit')
default_branch = git_repo.active_branch.name
conflict_file = Path('conflict_file.txt')

conflict_file.write_text('Hello World!', encoding='utf-8')
git_repo.git.add(conflict_file)
git_repo.index.commit('m1')

git_repo.git.checkout(base_commit)
git_repo.create_head('f1')
git_repo.git.checkout('f1')
conflict_file.write_text('Goodbye World!', encoding='utf-8')
git_repo.git.add(conflict_file)
git_repo.index.commit('f1')

git_repo.git.checkout(default_branch)
# Should error since there is a conflict
with contextlib.suppress(GitCommandError):
git_repo.git.merge('f1')

assert PromptFormatter()('{pygitstatus.conflicts}') == '{RED}×1{RESET}'


def test_curr_branch(git_repo):
Expand Down

0 comments on commit 8b96eab

Please sign in to comment.