From b496768efec3ad505a458de770897207f76f6dc5 Mon Sep 17 00:00:00 2001 From: Alexey Leshchenko Date: Thu, 19 Dec 2024 12:10:46 +0300 Subject: [PATCH] Update datetime import for consistency in test_class_method_with_params - Changed the datetime import to include timezone for improved clarity. - Updated the usage of datetime.now to utilize timezone.utc for better consistency in handling time zones. These changes enhance the accuracy of time-related tests in the test suite. --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ tests/test_main.py | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..01156eb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +# Changelog + +## [1.1.0] - 2024-03-18 + +### Added +- Instance-specific caching for both sync and async class methods +- Smart detection of instance methods vs standalone functions +- Improved logging for cache operations and method detection +- Better handling of ignored parameters in instance methods + +### Fixed +- Fixed cache key generation for instance methods to ensure proper instance separation +- Fixed infinite recursion issues in instance method detection +- Fixed handling of ignored parameters in instance methods +- Fixed cache invalidation for instance methods when code changes + +### Changed +- Improved instance method detection to exclude built-in types +- Updated documentation with instance method caching examples +- Simplified cache key generation logic +- Enhanced debug logging for better troubleshooting + +### Developer Notes +- Added comprehensive test coverage for instance method caching +- Added test cases for both sync and async instance methods +- Added tests for multiple instances of the same class +- Added tests for ignored parameters in instance methods + +## [1.0.0] - Previous version + +Initial release with basic caching functionality. diff --git a/tests/test_main.py b/tests/test_main.py index 3572588..6ab4c25 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -101,7 +101,7 @@ def get_data(): ... def test_class_method_with_params(cache): - from datetime import datetime, timedelta + from datetime import datetime, timedelta, timezone from pathlib import Path from perscache import Cache from perscache.storage import LocalFileStorage @@ -114,7 +114,7 @@ def cache_method(self, what: str, when: datetime): return f"What: {what}, Timestamp: {when.isoformat()}" pt = PerscacheTest() - pt.cache_method("This thing happened", datetime.now(tz=datetime.UTC)) + pt.cache_method("This thing happened", datetime.now(tz=timezone.utc)) def test_sync_class_method(cache):