Update tests/test_utils_path.py
Run CI Tests / test (push) Successful in 35s

This commit is contained in:
2025-07-28 23:08:35 +02:00
parent 3b98822b66
commit cea11d8673
+4 -6
View File
@@ -5,11 +5,11 @@ import shutil
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from slic.utils.path import *
import slic.utils.ask_yes_no
# Tests when user says yes to delete if the file exists
def test_can_create_all_files_user_says_yes():
your_module.ask_yes_No = lambda msg: True # Simulate "yes"
slic.utils.ask_yes_no.ask_yes_no = lambda msg: True
tmp_dir = tempfile.mkdtemp()
f1 = os.path.join(tmp_dir, "a.txt") # exists
@@ -35,7 +35,7 @@ def test_can_create_all_files_user_says_yes():
# Tests when user says no to delete if the file exists
def test_can_create_all_files_user_says_no():
your_module.ask_yes_No = lambda msg: False # Simulate "no"
slic.utils.ask_yes_no.ask_yes_no = lambda msg: False
tmp_dir = tempfile.mkdtemp()
f1 = os.path.join(tmp_dir, "file1.txt") # exists
@@ -65,7 +65,6 @@ def test_make_missing_dir_creates_folder():
# glob_files()
def test_glob_files_returns_matching_files_only():
"""Test that glob_files returns only files matching the pattern (*.txt)"""
tmp_dir = tempfile.mkdtemp()
Path(os.path.join(tmp_dir, "a.txt")).touch()
@@ -83,7 +82,6 @@ def test_glob_files_returns_matching_files_only():
# filter_files()
def test_filter_files_excludes_directories():
"""Test that filter_files excludes folders and only keeps files"""
tmp_dir = tempfile.mkdtemp()
f1 = Path(os.path.join(tmp_dir, "x.txt"))
@@ -99,6 +97,6 @@ def test_filter_files_excludes_directories():
result = filter_files([f1, f3, f2, d1])
result_names = sorted([p.name for p in result])
assert result_names == ["x.txt", "y.txt"]
assert result_names == ["x.txt", "y.log", "y.txt"]
shutil.rmtree(tmp_dir)