Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to move back to the original directory before cleaning up the tempdir #309

Merged
merged 2 commits into from
Jan 19, 2023
Merged
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
11 changes: 6 additions & 5 deletions tests/test_diff_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tempfile
from pathlib import Path
from textwrap import dedent
from unittest.mock import patch

import pytest

Expand Down Expand Up @@ -96,7 +97,7 @@ def test_name_include_untracked(git_diff):
),
],
)
def test_git_path_selection(mocker, diff, git_diff, include, exclude, expected):
def test_git_path_selection(diff, git_diff, include, exclude, expected):
old_cwd = os.getcwd()
with tempfile.TemporaryDirectory() as tmp_dir:
# change the working directory into the temp directory so that globs are working
Expand Down Expand Up @@ -127,15 +128,15 @@ def test_git_path_selection(mocker, diff, git_diff, include, exclude, expected):
)

# Get the source paths in the diff
mocker.patch.object(os.path, "abspath", lambda path: f"{tmp_dir}/{path}")
source_paths = diff.src_paths_changed()
with patch.object(os.path, "abspath", lambda path: f"{tmp_dir}/{path}"):
source_paths = diff.src_paths_changed()

# Validate the source paths
# They should be in alphabetical order
assert source_paths == expected

# change back to the previous working directory
os.chdir(old_cwd)
# change back to the previous working directory
os.chdir(old_cwd)


def test_git_source_paths(diff, git_diff):
Expand Down