Skip to content

Commit df1f035

Browse files
committed
cov fix: rectified shorten in test cov
1 parent d38c9dd commit df1f035

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

ellar/app/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __enter__(self) -> "ApplicationContext":
4747
if app_context is empty:
4848
# If app_context exist
4949
_application_context.set(self)
50-
if current_config._wrapped is not empty:
50+
if current_config._wrapped is not empty: # pragma: no cover
5151
# ensure current_config is in sync with running application context.
5252
current_config._wrapped = self.config
5353

ellar/common/utils/functional.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __reduce__(self):
9393
self._setup()
9494
return (unpickle_lazyobject, (self._wrapped,))
9595

96-
def __copy__(self):
96+
def __copy__(self): # pragma: no cover
9797
if self._wrapped is empty:
9898
# If uninitialized, copy the wrapper. Use type(self), not
9999
# self.__class__, because the latter is proxied.
@@ -176,7 +176,7 @@ def __repr__(self) -> str:
176176
repr_attr = self._wrapped
177177
return "<%s: %r>" % (type(self).__name__, repr_attr)
178178

179-
def __copy__(self) -> t.Any:
179+
def __copy__(self) -> t.Any: # pragma: no cover
180180
if self._wrapped is empty:
181181
# If uninitialized, copy the wrapper. Use SimpleLazyObject, not
182182
# self.__class__, because the latter is proxied.
@@ -185,7 +185,7 @@ def __copy__(self) -> t.Any:
185185
# If initialized, return a copy of the wrapped object.
186186
return copy.copy(self._wrapped)
187187

188-
def __deepcopy__(self, memo: t.Any) -> t.Any:
188+
def __deepcopy__(self, memo: t.Any) -> t.Any: # pragma: no cover
189189
if self._wrapped is empty:
190190
# We have to use SimpleLazyObject, not self.__class__, because the
191191
# latter is proxied.

tests/test_utils/test_lazy_objects.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ def test_getattr(self):
6363
obj = self.lazy_wrap(Foo())
6464
assert obj.foo == "bar"
6565

66+
def test_delattr_fails(self):
67+
obj = self.lazy_wrap(Foo())
68+
with pytest.raises(TypeError):
69+
del obj._wrapped
70+
6671
def test_getattr_falsey(self):
6772
class Thing:
6873
def __getattr__(self, key):
@@ -87,7 +92,16 @@ def test_setattr2(self):
8792
assert obj.bar == "baz"
8893

8994
def test_delattr(self):
90-
obj = self.lazy_wrap(Foo())
95+
class A:
96+
def __init__(self):
97+
self.foo = "bar"
98+
99+
obj = self.lazy_wrap(A())
100+
del obj.foo
101+
102+
with pytest.raises(AttributeError):
103+
assert obj.foo
104+
91105
obj.bar = "baz"
92106
assert obj.bar == "baz"
93107
del obj.bar

0 commit comments

Comments
 (0)