Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
2c190ab1
Commit
2c190ab1
authored
Oct 11, 2022
by
Chad Crawford
Committed by
Bjorn Neergaard
Oct 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Add post init check for `FileCache` hash type.
parent
c2b1fb3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
src/poetry/utils/cache.py
+6
-0
tests/utils/test_cache.py
+6
-0
No files found.
src/poetry/utils/cache.py
View file @
2c190ab1
...
@@ -100,6 +100,12 @@ class FileCache(Generic[T]):
...
@@ -100,6 +100,12 @@ class FileCache(Generic[T]):
path
:
Path
path
:
Path
hash_type
:
str
=
"sha256"
hash_type
:
str
=
"sha256"
def
__post_init__
(
self
)
->
None
:
if
self
.
hash_type
not
in
_HASHES
:
raise
ValueError
(
f
"FileCache.hash_type is unknown value: '{self.hash_type}'."
)
def
get
(
self
,
key
:
str
)
->
T
|
None
:
def
get
(
self
,
key
:
str
)
->
T
|
None
:
return
self
.
_get_payload
(
key
)
return
self
.
_get_payload
(
key
)
...
...
tests/utils/test_cache.py
View file @
2c190ab1
...
@@ -85,6 +85,12 @@ def cachy_dict_cache() -> CacheManager:
...
@@ -85,6 +85,12 @@ def cachy_dict_cache() -> CacheManager:
return
patch_cachy
(
cache
)
return
patch_cachy
(
cache
)
def
test_cache_validates
(
repository_cache_dir
:
Path
)
->
None
:
with
pytest
.
raises
(
ValueError
)
as
e
:
FileCache
(
repository_cache_dir
/
"cache"
,
hash_type
=
"unknown"
)
assert
str
(
e
.
value
)
==
"FileCache.hash_type is unknown value: 'unknown'."
@pytest.mark.parametrize
(
"cache_name"
,
[
"cachy_file_cache"
,
"poetry_file_cache"
])
@pytest.mark.parametrize
(
"cache_name"
,
[
"cachy_file_cache"
,
"poetry_file_cache"
])
def
test_cache_get_put_has
(
cache_name
:
str
,
request
:
FixtureRequest
)
->
None
:
def
test_cache_get_put_has
(
cache_name
:
str
,
request
:
FixtureRequest
)
->
None
:
cache
=
request
.
getfixturevalue
(
cache_name
)
cache
=
request
.
getfixturevalue
(
cache_name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment