From 8b96eab440db3cf239bd31a6abda4082f1da3b25 Mon Sep 17 00:00:00 2001 From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com> Date: Tue, 31 Dec 2024 19:30:56 -0500 Subject: [PATCH] only use tmp_path in test_conflict --- tests/test_xontrib.py | 47 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/tests/test_xontrib.py b/tests/test_xontrib.py index cf62489..eab809f 100644 --- a/tests/test_xontrib.py +++ b/tests/test_xontrib.py @@ -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):