From 860c83872b7d93a25acfb331ccf1d00ebf2e302a Mon Sep 17 00:00:00 2001 From: David Hotham Date: Thu, 6 Apr 2023 16:23:57 +0100 Subject: [PATCH] Avoid resource warning false positive in unit test (#7769) --- tests/console/commands/test_add.py | 3 +-- tests/console/commands/test_build.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/console/commands/test_add.py b/tests/console/commands/test_add.py index 5c2a1bafe1f..516934c4b32 100644 --- a/tests/console/commands/test_add.py +++ b/tests/console/commands/test_add.py @@ -52,8 +52,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester: @pytest.fixture() def old_tester(tester: CommandTester) -> CommandTester: - with pytest.warns(DeprecationWarning): - tester.command.installer.use_executor(False) + tester.command.installer._use_executor = False return tester diff --git a/tests/console/commands/test_build.py b/tests/console/commands/test_build.py index 6bb71aace71..2d7ed87007a 100644 --- a/tests/console/commands/test_build.py +++ b/tests/console/commands/test_build.py @@ -39,6 +39,8 @@ def test_build_with_multiple_readme_files( assert wheel_file.exists() assert wheel_file.stat().st_size > 0 - sdist_content = tarfile.open(sdist_file).getnames() + with tarfile.open(sdist_file) as tf: + sdist_content = tf.getnames() + assert "my_package-0.1/README-1.rst" in sdist_content assert "my_package-0.1/README-2.rst" in sdist_content