From b98ebc8a693f790d09fd1aa1bf764ac6a31f08d4 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 9 Jun 2021 10:36:37 -0400 Subject: [PATCH] island: Remove tmpdir cleanup code from test_utils.py Pytest automatically cleans up tmpdir fixtures older than 3 runs. See https://docs.pytest.org/en/6.2.x/tmpdir.html#the-default-base-temporary-directory Windows10 and Linux will automatically clean their temp directories. --- .../monkey_island/cc/environment/test_utils.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/environment/test_utils.py b/monkey/tests/unit_tests/monkey_island/cc/environment/test_utils.py index 3d9898d64..c373bc84a 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/environment/test_utils.py +++ b/monkey/tests/unit_tests/monkey_island/cc/environment/test_utils.py @@ -1,5 +1,4 @@ import os -import shutil import stat import pytest @@ -11,22 +10,16 @@ from monkey_island.cc.environment.utils import create_secure_directory, is_windo def test_path_nested(tmpdir): nested_path = "test1/test2/test3" path = os.path.join(tmpdir, nested_path) - yield path - try: - shutil.rmtree(os.path.join(tmpdir, "test1")) - except Exception: - pass + + return path @pytest.fixture def test_path(tmpdir): test_path = "test1" path = os.path.join(tmpdir, test_path) - yield path - try: - shutil.rmtree(path) - except Exception: - pass + + return path def test_create_secure_directory__parent_dirs(test_path_nested):