pytest-pickle-cache 0.1.3__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ from .plugin import UseCache
4
+
5
+ __all__ = ["UseCache"]
@@ -3,17 +3,17 @@ from __future__ import annotations
3
3
  import base64
4
4
  import binascii
5
5
  import pickle
6
- from typing import TYPE_CHECKING
6
+ from collections.abc import Callable
7
+ from typing import TypeAlias, TypeVar
7
8
 
8
9
  import pytest
9
10
 
10
- if TYPE_CHECKING:
11
- from collections.abc import Callable
12
- from typing import Any
11
+ T = TypeVar("T")
12
+ UseCache: TypeAlias = Callable[[str, Callable[[], T]], T]
13
13
 
14
14
 
15
15
  @pytest.fixture(scope="session")
16
- def use_cache(request: pytest.FixtureRequest) -> Callable[[str, Callable], Any]:
16
+ def use_cache(request: pytest.FixtureRequest) -> UseCache[T]:
17
17
  """A pytest fixture to use cache.
18
18
 
19
19
  This fixture provides a caching mechanism for pytest, allowing you to
@@ -21,21 +21,22 @@ def use_cache(request: pytest.FixtureRequest) -> Callable[[str, Callable], Any]:
21
21
  and deserialized using pickle and base64 encoding.
22
22
  """
23
23
 
24
- def use_cache(key: str, create: Callable[[], Any]) -> Any:
24
+ def use_cache(key: str, create: Callable[[], T]) -> T:
25
25
  """Retrieve a cached result or execute the function if not cached.
26
26
 
27
27
  Args:
28
28
  key (str): The key to identify the cached result.
29
- func (Callable[[], Any]): The function to execute if the result is
29
+ create (Callable[[], T]): The function to execute if the result is
30
30
  not cached. The result of the function is serialized and stored
31
31
  in the cache for future use.
32
32
 
33
33
  Returns:
34
- Any: The cached result or the result of the executed function.
34
+ T: The cached result or the result of the executed function.
35
+
35
36
  """
36
37
  try:
37
- if value := request.config.cache.get(key, None):
38
- return pickle.loads(base64.b64decode(value))
38
+ if value := request.config.cache.get(key, None): # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
39
+ return pickle.loads(base64.b64decode(value)) # pyright: ignore[reportUnknownArgumentType]
39
40
  except (pickle.UnpicklingError, binascii.Error):
40
41
  request.config.cache.set(key, None)
41
42
 
@@ -1,32 +1,35 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: pytest-pickle-cache
3
- Version: 0.1.3
3
+ Version: 0.2.0
4
4
  Summary: A pytest plugin for caching test results using pickle.
5
- Project-URL: Documentation, https://github.com/daizutabi/pytest-pickle-cache
6
- Project-URL: Source, https://github.com/daizutabi/pytest-pickle-cache
7
- Project-URL: Issues, https://github.com/daizutabi/pytest-pickle-cache/issues
5
+ Author: daizutabi
8
6
  Author-email: daizutabi <daizutabi@gmail.com>
9
7
  License: MIT License
10
-
11
- Copyright (c) 2020-present daizutabi <daizutabi@gmail.com>
12
-
13
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
- License-File: LICENSE
8
+
9
+ Copyright (c) 2020-present daizutabi <daizutabi@gmail.com>
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ Classifier: Development Status :: 4 - Beta
19
17
  Classifier: Framework :: Pytest
20
18
  Classifier: Intended Audience :: Developers
21
19
  Classifier: License :: OSI Approved :: MIT License
22
- Classifier: Programming Language :: Python
20
+ Classifier: Operating System :: OS Independent
23
21
  Classifier: Programming Language :: Python :: 3.10
24
22
  Classifier: Programming Language :: Python :: 3.11
25
23
  Classifier: Programming Language :: Python :: 3.12
26
24
  Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
+ Classifier: Programming Language :: Python
27
27
  Classifier: Topic :: Software Development :: Testing
28
+ Requires-Dist: pytest>=9
28
29
  Requires-Python: >=3.10
29
- Requires-Dist: pytest>=7
30
+ Project-URL: Documentation, https://github.com/daizutabi/pytest-pickle-cache
31
+ Project-URL: Source, https://github.com/daizutabi/pytest-pickle-cache
32
+ Project-URL: Issues, https://github.com/daizutabi/pytest-pickle-cache/issues
30
33
  Description-Content-Type: text/markdown
31
34
 
32
35
  # pytest-pickle-cache
@@ -0,0 +1,7 @@
1
+ pytest_pickle_cache/__init__.py,sha256=7KcBqV8Y2fyGWlcMSEU4BWg6l-AaIUI7qzRVm5YS8-g,89
2
+ pytest_pickle_cache/plugin.py,sha256=eSDrZqsBCy5rSrjrSfMsju6Xq4veQVcH4IU8ryaX4Ak,1657
3
+ pytest_pickle_cache/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ pytest_pickle_cache-0.2.0.dist-info/WHEEL,sha256=jROcLULcdzropX2J55opKw4UHhPFREZax2XzS-Mvpxs,80
5
+ pytest_pickle_cache-0.2.0.dist-info/entry_points.txt,sha256=hVUf19WIK3KEAkKsTo5sXe1jb6icqLodl5QTUc1z9m0,54
6
+ pytest_pickle_cache-0.2.0.dist-info/METADATA,sha256=G3CaxwEE6VXHFSsYiALGahmfNQTNkh3aW0MRRF4XkF0,6242
7
+ pytest_pickle_cache-0.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: uv 0.10.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,2 +1,3 @@
1
1
  [pytest11]
2
2
  pickle_cache = pytest_pickle_cache.plugin
3
+
@@ -1,8 +0,0 @@
1
- pytest_pickle_cache/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pytest_pickle_cache/plugin.py,sha256=nSao-EHMms5Htd9tZ8bvri9LlLq32f7ByoDl8YYpbF4,1533
3
- pytest_pickle_cache/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- pytest_pickle_cache-0.1.3.dist-info/METADATA,sha256=cn2j9Y4ctzeIewYGqW1ePuDwIf4eIJCRhvARa9qtiyQ,6097
5
- pytest_pickle_cache-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
- pytest_pickle_cache-0.1.3.dist-info/entry_points.txt,sha256=OEfVnY9Bw249Hf7T6TAPEw69R_FbjipFlDpo26eohrc,53
7
- pytest_pickle_cache-0.1.3.dist-info/licenses/LICENSE,sha256=dbO9NY-nQXzIS5St3j3rPUd7gm5r6pczFYaNy5GVNdI,1105
8
- pytest_pickle_cache-0.1.3.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020-present daizutabi <daizutabi@gmail.com>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.