From 9fb8ad6edbc319bbb5d213ee120facb3b354bad5 Mon Sep 17 00:00:00 2001 From: Alexey Leshchenko Date: Tue, 12 Nov 2024 15:38:24 +0300 Subject: [PATCH] Better tests --- tests/test_nocache.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/test_nocache.py b/tests/test_nocache.py index 89b4fea..01621cb 100644 --- a/tests/test_nocache.py +++ b/tests/test_nocache.py @@ -1,13 +1,19 @@ from perscache import NoCache +import asyncio def test_no_cache_with_parentheses(): - + counter = 0 cache = NoCache() @cache() def dummy_func(): + nonlocal counter + counter += 1 return 'NoCache with parentheses' assert dummy_func() == 'NoCache with parentheses' + assert dummy_func() == 'NoCache with parentheses' + assert counter == 2 + def test_no_cache_without_parentheses(): cache = NoCache() @@ -17,3 +23,23 @@ def dummy_func(): return 'NoCache without parentheses' assert dummy_func() == 'NoCache without parentheses' + + +async def test_no_cache_with_parentheses_async(): + cache = NoCache() + + @cache() + async def dummy_func(): + return 'NoCache with parentheses async' + + assert await dummy_func() == 'NoCache with parentheses async' + + +async def test_no_cache_without_parentheses_async(): + cache = NoCache() + + @cache + async def dummy_func(): + return 'NoCache without parentheses async' + + assert await dummy_func() == 'NoCache without parentheses async'