Skip to content

Commit

Permalink
tests: Fix ResourceWarning due to dangling TarFile.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentzo committed Apr 25, 2023
1 parent bf8f2ee commit 0e3a240
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test_git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ def test_ignore(contents, exclude, tmpdir, git_env, monkeypatch):

repo_tar_path = os_path_join(tmpdir.strpath, 'repo.tar')
repo.archive(repo_tar_path, exclude=exclude)
repo_tar = TarFile(repo_tar_path, format=PAX_FORMAT, encoding='utf-8')

expected = make_expected_tree(contents, exclude)
actual = make_actual_tree(repo_tar)
with TarFile(repo_tar_path, format=PAX_FORMAT, encoding='utf-8') as repo_tar:
expected = make_expected_tree(contents, exclude)
actual = make_actual_tree(repo_tar)

assert actual == expected

Expand All @@ -426,10 +426,10 @@ def test_cli(tmpdir, git_env, monkeypatch):

repo_tar_path = os_path_join(tmpdir.strpath, 'repo.tar')
git_archive_all.main(['git_archive_all.py', '--prefix', '', '-C', repo_path, repo_tar_path])
repo_tar = TarFile(repo_tar_path, format=PAX_FORMAT, encoding='utf-8')

expected = make_expected_tree(contents)
actual = make_actual_tree(repo_tar)
with TarFile(repo_tar_path, format=PAX_FORMAT, encoding='utf-8') as repo_tar:
expected = make_expected_tree(contents)
actual = make_actual_tree(repo_tar)

assert actual == expected

Expand Down

0 comments on commit 0e3a240

Please sign in to comment.