openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
a6e9db84c1952c856c8449536714b7a7daa22d2e

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/test_utils/test_proxy.py

23lines · modeblame

2e7e897aStainless Bot2 years ago1import operator
2from typing import Any
3from typing_extensions import override
4
5from openai._utils import LazyProxy
6
7
8class RecursiveLazyProxy(LazyProxy[Any]):
9@override
10def __load__(self) -> Any:
11return self
12
13def __call__(self, *_args: Any, **_kwds: Any) -> Any:
14raise RuntimeError("This should never be called!")
15
16
17def test_recursive_proxy() -> None:
18proxy = RecursiveLazyProxy()
19assert repr(proxy) == "RecursiveLazyProxy"
20assert str(proxy) == "RecursiveLazyProxy"
21assert dir(proxy) == []
e967f5a5Stainless Bot2 years ago22assert type(proxy).__name__ == "RecursiveLazyProxy"
2e7e897aStainless Bot2 years ago23assert type(operator.attrgetter("name.foo.bar.baz")(proxy)).__name__ == "RecursiveLazyProxy"