Skip to content

Commit

Permalink
Better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leshchenko1979 committed Nov 12, 2024
1 parent 2bbb326 commit 9fb8ad6
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/test_nocache.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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'

0 comments on commit 9fb8ad6

Please sign in to comment.