Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typing to propcache_module in tests #33

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions tests/test_cached_property.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from operator import not_
from types import ModuleType

import pytest


def test_cached_property(propcache_module) -> None:
def test_cached_property(propcache_module: ModuleType) -> None:
class A:
def __init__(self):
self._cache = {}
Expand All @@ -16,7 +17,7 @@ def prop(self):
assert a.prop == 1


def test_cached_property_class(propcache_module) -> None:
def test_cached_property_class(propcache_module: ModuleType) -> None:
class A:
def __init__(self):
"""Init."""
Expand All @@ -30,7 +31,7 @@ def prop(self):
assert A.prop.__doc__ == "Docstring."


def test_cached_property_without_cache(propcache_module) -> None:
def test_cached_property_without_cache(propcache_module: ModuleType) -> None:
class A:

__slots__ = ()
Expand All @@ -48,7 +49,7 @@ def prop(self):
a.prop = 123


def test_cached_property_check_without_cache(propcache_module) -> None:
def test_cached_property_check_without_cache(propcache_module: ModuleType) -> None:
class A:

__slots__ = ()
Expand All @@ -65,7 +66,7 @@ def prop(self):
assert a.prop == 1


def test_cached_property_caching(propcache_module) -> None:
def test_cached_property_caching(propcache_module: ModuleType) -> None:

class A:
def __init__(self):
Expand All @@ -80,7 +81,7 @@ def prop(self):
assert 1 == a.prop


def test_cached_property_class_docstring(propcache_module) -> None:
def test_cached_property_class_docstring(propcache_module: ModuleType) -> None:

class A:
def __init__(self):
Expand All @@ -94,7 +95,7 @@ def prop(self):
assert "Docstring." == A.prop.__doc__


def test_set_name(propcache_module) -> None:
def test_set_name(propcache_module: ModuleType) -> None:
"""Test that the __set_name__ method is called and checked."""

class A:
Expand All @@ -110,7 +111,7 @@ def prop(self):
A.prop.__set_name__(A, "something_else")


def test_get_without_set_name(propcache_module) -> None:
def test_get_without_set_name(propcache_module: ModuleType) -> None:
"""Test that get without __set_name__ fails."""
cp = propcache_module.cached_property(not_)

Expand Down
18 changes: 11 additions & 7 deletions tests/test_under_cached_property.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from types import ModuleType

import pytest


def test_under_cached_property(propcache_module) -> None:
def test_under_cached_property(propcache_module: ModuleType) -> None:
class A:
def __init__(self):
self._cache = {}
Expand All @@ -14,7 +16,7 @@ def prop(self):
assert a.prop == 1


def test_under_cached_property_class(propcache_module) -> None:
def test_under_cached_property_class(propcache_module: ModuleType) -> None:
class A:
def __init__(self):
"""Init."""
Expand All @@ -28,7 +30,7 @@ def prop(self):
assert A.prop.__doc__ == "Docstring."


def test_under_cached_property_assignment(propcache_module) -> None:
def test_under_cached_property_assignment(propcache_module: ModuleType) -> None:
class A:
def __init__(self):
self._cache = {}
Expand All @@ -43,7 +45,7 @@ def prop(self):
a.prop = 123


def test_under_cached_property_without_cache(propcache_module) -> None:
def test_under_cached_property_without_cache(propcache_module: ModuleType) -> None:
class A:
def __init__(self):
pass
Expand All @@ -58,7 +60,9 @@ def prop(self):
a.prop = 123


def test_under_cached_property_check_without_cache(propcache_module) -> None:
def test_under_cached_property_check_without_cache(
propcache_module: ModuleType,
) -> None:
class A:
def __init__(self):
pass
Expand All @@ -72,7 +76,7 @@ def prop(self):
assert a.prop == 1


def test_under_cached_property_caching(propcache_module) -> None:
def test_under_cached_property_caching(propcache_module: ModuleType) -> None:

class A:
def __init__(self):
Expand All @@ -87,7 +91,7 @@ def prop(self):
assert 1 == a.prop


def test_under_cached_property_class_docstring(propcache_module) -> None:
def test_under_cached_property_class_docstring(propcache_module: ModuleType) -> None:
class A:
def __init__(self):
"""Init."""
Expand Down
Loading