-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/leshchenko1979/perscache
- Loading branch information
Showing
3 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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() | ||
|
||
@cache | ||
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' |