Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
2062f725
Commit
2062f725
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Test Cache lru option
parent
0de46cca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_cache.py
+29
-0
29 additions, 0 deletions
tests/test_cache.py
with
29 additions
and
0 deletions
tests/test_cache.py
+
29
−
0
View file @
2062f725
...
...
@@ -113,7 +113,36 @@ def test_expiry():
with
pytest
.
raises
(
cache
.
Expired
):
c
.
get
(
0
)
with
pytest
.
raises
(
cache
.
Expired
):
c
.
get
(
1
)
assert
c
.
get
(
1
,
default
=
'
default
'
)
==
'
default
'
# And that the cache is empty
assert
len
(
c
)
==
0
def
test_lru
():
c
=
cache
.
Cache
(
maxsize
=
3
,
lru
=
True
)
c
[
0
]
=
'
0
'
c
[
1
]
=
'
1
'
c
[
2
]
=
'
2
'
c
[
3
]
=
'
3
'
# normal behaviour - first inserted
# is dropped
with
pytest
.
raises
(
KeyError
):
assert
c
.
get
(
0
)
# lru behaviour - oldest accessed is
# dropped
c
[
1
]
c
[
4
]
=
'
4
'
with
pytest
.
raises
(
KeyError
):
c
[
2
]
c
[
1
]
c
[
3
]
c
[
4
]
assert
len
(
c
)
==
3
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment