1212
1313script_dir = pathlib .Path (__file__ ).parent .parent .parent
1414sys .path .append (os .fspath (script_dir ))
15- from vscode_pytest import has_symlink_parent # noqa: E402
15+ from vscode_pytest import cached_fsdecode , has_symlink_parent # noqa: E402
1616
1717
1818def test_has_symlink_parent_with_symlink ():
@@ -33,3 +33,25 @@ def test_has_symlink_parent_without_symlink():
3333 folder_path = TEST_DATA_PATH / "unittest_folder" / "test_add.py"
3434 # Check that has_symlink_parent correctly identifies that there are no symbolic links
3535 assert not has_symlink_parent (folder_path )
36+
37+
38+ def test_cached_fsdecode ():
39+ """Test that cached_fsdecode correctly caches path-to-string conversions."""
40+ # Create a test path
41+ test_path = TEST_DATA_PATH / "simple_pytest.py"
42+
43+ # First call should compute and cache
44+ result1 = cached_fsdecode (test_path )
45+ assert result1 == os .fspath (test_path )
46+ assert isinstance (result1 , str )
47+
48+ # Second call should return cached value (same object)
49+ result2 = cached_fsdecode (test_path )
50+ assert result2 == result1
51+ assert result2 is result1 # Should be the same object from cache
52+
53+ # Different path should be cached independently
54+ test_path2 = TEST_DATA_PATH / "parametrize_tests.py"
55+ result3 = cached_fsdecode (test_path2 )
56+ assert result3 == os .fspath (test_path2 )
57+ assert result3 != result1
0 commit comments