From 2806efeb49179020ace22b99730531568e624406 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sun, 20 Oct 2024 21:13:49 +0200 Subject: [PATCH] Sharpen asserts in an attempt to debug failing test --- tests/test_fs.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_fs.py diff --git a/tests/test_fs.py b/tests/test_fs.py new file mode 100644 index 000000000..372d298aa --- /dev/null +++ b/tests/test_fs.py @@ -0,0 +1,19 @@ +import os +import tempfile + +from hatchling.utils.fs import locate_file + + +def test_locate_file_with_symlinks(): + with tempfile.TemporaryDirectory() as temp_dir: + # Create a directory structure with a cycle + os.makedirs(os.path.join(temp_dir, 'a', 'b', 'c')) + os.symlink(temp_dir, os.path.join(temp_dir, 'a', 'b', 'c', 'link_to_root')) + + # Create test file + with open(os.path.join(temp_dir, 'target_file.txt'), 'w') as f: + f.write('target') + + # Test cases + # assert locate_file(os.path.join(temp_dir, 'a', 'b', 'c', 'link_to_root', 'a', 'b'), 'target_file.txt') == os.path.join(temp_dir, 'target_file.txt') + assert locate_file(os.path.join(temp_dir, 'a', 'b', 'c', 'link_to_root', 'a', 'b'), 'non_existent.txt') is None