Skip to content

Commit 0e3a240

Browse files
committed
tests: Fix ResourceWarning due to dangling TarFile.
1 parent bf8f2ee commit 0e3a240

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test_git_archive_all.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,10 @@ def test_ignore(contents, exclude, tmpdir, git_env, monkeypatch):
400400

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

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

408408
assert actual == expected
409409

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

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

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

434434
assert actual == expected
435435

0 commit comments

Comments
 (0)