openai/openai-python

Public

mirrored fromhttps://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2bfec1a2f0be308053924ba673398cd18a038422

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/test_utils/test_proxy.py

23lines · modecode

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