-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
507bfb0
commit 3d30237
Showing
2 changed files
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from contextlib import closing | ||
from cachecontrol.streaming_cache import ExampleCache | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize('v', [b'fizz', b'buzz']) | ||
def test_read_returns_what_you_wrote(v): | ||
with closing(ExampleCache()) as cache: | ||
with closing(cache.open_write('foo')) as w: | ||
w.write(v) | ||
w.commit() | ||
with closing(cache.open_read('foo')) as r: | ||
got = r.read() | ||
assert got == v | ||
|
||
|
||
def test_cache_remembers_more_than_one_value(): | ||
with closing(ExampleCache()) as cache: | ||
with closing(cache.open_write('foo')) as w: | ||
w.write(b'one') | ||
w.commit() | ||
with closing(cache.open_write('bar')) as w: | ||
w.write(b'two') | ||
w.commit() | ||
with closing(cache.open_read('foo')) as r: | ||
got = r.read() | ||
assert got == b'one' | ||
with closing(cache.open_read('bar')) as r: | ||
got = r.read() | ||
assert got == b'two' |