-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(internal): add tests for proxy change (#260)
- Loading branch information
1 parent
dd1ba52
commit b3083eb
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import operator | ||
from typing import Any | ||
from typing_extensions import override | ||
|
||
from anthropic._utils import LazyProxy | ||
|
||
|
||
class RecursiveLazyProxy(LazyProxy[Any]): | ||
@override | ||
def __load__(self) -> Any: | ||
return self | ||
|
||
def __call__(self, *_args: Any, **_kwds: Any) -> Any: | ||
raise RuntimeError("This should never be called!") | ||
|
||
|
||
def test_recursive_proxy() -> None: | ||
proxy = RecursiveLazyProxy() | ||
assert repr(proxy) == "RecursiveLazyProxy" | ||
assert str(proxy) == "RecursiveLazyProxy" | ||
assert dir(proxy) == [] | ||
assert getattr(type(proxy), "__name__") == "RecursiveLazyProxy" | ||
assert type(operator.attrgetter("name.foo.bar.baz")(proxy)).__name__ == "RecursiveLazyProxy" |