From ff8c666e3b5b0919f7b8c8d1a5c2442daf22a372 Mon Sep 17 00:00:00 2001 From: nicholasmhughes Date: Wed, 29 Jun 2022 11:28:30 -0400 Subject: [PATCH] change test to use direct import of file module --- .../functional/modules/file/test_rmdir.py | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/tests/pytests/functional/modules/file/test_rmdir.py b/tests/pytests/functional/modules/file/test_rmdir.py index 0dd6bc0476b3..caad6051bacb 100644 --- a/tests/pytests/functional/modules/file/test_rmdir.py +++ b/tests/pytests/functional/modules/file/test_rmdir.py @@ -2,17 +2,13 @@ import time import pytest +import salt.modules.file as file pytestmark = [ pytest.mark.windows_whitelisted, ] -@pytest.fixture(scope="module") -def file(modules): - return modules.file - - @pytest.fixture(scope="function") def single_empty_dir(tmp_path): yield str(tmp_path) @@ -68,48 +64,46 @@ def nested_dirs_with_files(tmp_path): yield str(tmp_path) -def test_rmdir_success_with_default_options(file, single_empty_dir): +def test_rmdir_success_with_default_options(single_empty_dir): assert file.rmdir(single_empty_dir) is True assert not os.path.isdir(single_empty_dir) assert not os.path.exists(single_empty_dir) -def test_rmdir_failure_with_default_options(file, single_dir_with_file): +def test_rmdir_failure_with_default_options(single_dir_with_file): assert file.rmdir(single_dir_with_file) is False assert os.path.isdir(single_dir_with_file) -def test_rmdir_single_dir_success_with_recurse(file, single_empty_dir): +def test_rmdir_single_dir_success_with_recurse(single_empty_dir): assert file.rmdir(single_empty_dir, recurse=True) is True assert not os.path.isdir(single_empty_dir) assert not os.path.exists(single_empty_dir) -def test_rmdir_single_dir_failure_with_recurse(file, single_dir_with_file): +def test_rmdir_single_dir_failure_with_recurse(single_dir_with_file): assert file.rmdir(single_dir_with_file, recurse=True) is False assert os.path.isdir(single_dir_with_file) -def test_rmdir_nested_empty_dirs_failure_with_default_options(file, nested_empty_dirs): +def test_rmdir_nested_empty_dirs_failure_with_default_options(nested_empty_dirs): assert file.rmdir(nested_empty_dirs) is False assert os.path.isdir(nested_empty_dirs) -def test_rmdir_nested_empty_dirs_success_with_recurse(file, nested_empty_dirs): +def test_rmdir_nested_empty_dirs_success_with_recurse(nested_empty_dirs): assert file.rmdir(nested_empty_dirs, recurse=True) is True assert not os.path.isdir(nested_empty_dirs) assert not os.path.exists(nested_empty_dirs) -def test_rmdir_nested_dirs_with_files_failure_with_recurse( - file, nested_dirs_with_files -): +def test_rmdir_nested_dirs_with_files_failure_with_recurse(nested_dirs_with_files): assert file.rmdir(nested_dirs_with_files, recurse=True) is False assert os.path.isdir(nested_dirs_with_files) def test_rmdir_verbose_nested_dirs_with_files_failure_with_recurse( - file, nested_dirs_with_files + nested_dirs_with_files, ): ret = file.rmdir(nested_dirs_with_files, recurse=True, verbose=True) assert ret["result"] is False @@ -118,7 +112,7 @@ def test_rmdir_verbose_nested_dirs_with_files_failure_with_recurse( assert os.path.isdir(nested_dirs_with_files) -def test_rmdir_verbose_success(file, single_empty_dir): +def test_rmdir_verbose_success(single_empty_dir): ret = file.rmdir(single_empty_dir, verbose=True) assert ret["result"] is True assert ret["deleted"][0] == single_empty_dir @@ -127,7 +121,7 @@ def test_rmdir_verbose_success(file, single_empty_dir): assert not os.path.exists(single_empty_dir) -def test_rmdir_verbose_failure(file, single_dir_with_file): +def test_rmdir_verbose_failure(single_dir_with_file): ret = file.rmdir(single_dir_with_file, verbose=True) assert ret["result"] is False assert not ret["deleted"] @@ -135,7 +129,7 @@ def test_rmdir_verbose_failure(file, single_dir_with_file): assert os.path.isdir(single_dir_with_file) -def test_rmdir_nested_empty_dirs_recurse_older_than(file, nested_empty_dirs): +def test_rmdir_nested_empty_dirs_recurse_older_than(nested_empty_dirs): ret = file.rmdir(nested_empty_dirs, recurse=True, verbose=True, older_than=1) assert ret["result"] is True assert len(ret["deleted"]) == 8 @@ -143,7 +137,7 @@ def test_rmdir_nested_empty_dirs_recurse_older_than(file, nested_empty_dirs): assert os.path.isdir(nested_empty_dirs) -def test_rmdir_nested_empty_dirs_recurse_not_older_than(file, nested_empty_dirs): +def test_rmdir_nested_empty_dirs_recurse_not_older_than(nested_empty_dirs): ret = file.rmdir(nested_empty_dirs, recurse=True, verbose=True, older_than=3) assert ret["result"] is True assert len(ret["deleted"]) == 0