Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure calling abspath in file cache #3

Merged
merged 5 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions permacache/out_file_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def do_copy_file(file_cache, out_path):
"""
Helper function for do_copy_files that copies a single file.
"""
out_path = os.path.abspath(out_path)
file_cache_valid = {}
for path in file_cache:
try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="permacache",
version="3.7.1",
version="3.7.2",
author="Kavi Gupta",
author_email="[email protected]",
description="Permanant cache.",
Expand Down
16 changes: 16 additions & 0 deletions tests/test_out_file_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ def test_basic(self):
self.assertCounter(1)
self.assertAtPath("abc", "246")

def test_overwrite_self_same_path(self):
self.assertCounter(0)
self.assertEqual(self.f(123, out_file=self.out_path("abc")), [123, 2])
self.assertCounter(1)
self.assertEqual(self.f(123, out_file=self.out_path("abc")), [123, 2])
self.assertCounter(1)
self.assertAtPath("abc", "246")

def test_overwrite_self_same_abspath(self):
self.assertCounter(0)
self.assertEqual(self.f(123, out_file=self.out_path("abc")), [123, 2])
self.assertCounter(1)
self.assertEqual(self.f(123, out_file=self.out_path("./abc")), [123, 2])
self.assertCounter(1)
self.assertAtPath("abc", "246")

def test_basic_overwritten(self):
self.assertCounter(0)
self.assertEqual(self.f(123, out_file=self.out_path("abc")), [123, 2])
Expand Down
Loading