Skip to content

Commit e79e888

Browse files
committed
Port fixes from elasticsearch-py pull request
1 parent c655308 commit e79e888

File tree

2 files changed

+12
-40
lines changed

2 files changed

+12
-40
lines changed

elasticsearch_serverless/_sync/client/utils.py

-7
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class Stability(Enum):
7070
STABLE = auto()
7171
BETA = auto()
7272
EXPERIMENTAL = auto()
73-
DEPRECATED = auto()
7473

7574

7675
_TYPE_HOST = Union[str, Mapping[str, Union[str, int]], NodeConfig]
@@ -454,12 +453,6 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
454453
category=GeneralAvailabilityWarning,
455454
stacklevel=warn_stacklevel(),
456455
)
457-
elif stability == Stability.DEPRECATED:
458-
warnings.warn(
459-
f"This API was deprecated in Elasticsearch {version}. {message}",
460-
category=DeprecationWarning,
461-
stacklevel=warn_stacklevel(),
462-
)
463456

464457
return api(*args, **kwargs)
465458

test_elasticsearch_serverless/test_client/test_utils.py

+12-33
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import warnings
2020

21+
import pytest
22+
2123
from elasticsearch_serverless._sync.client.utils import (
2224
Stability,
2325
_quote,
@@ -62,43 +64,20 @@ def test_beta(self, recwarn):
6264
def func_beta(*args, **kwargs):
6365
pass
6466

65-
func_beta()
66-
67-
assert len(recwarn) == 1
68-
user_warning = recwarn.pop(GeneralAvailabilityWarning)
69-
assert user_warning.category == GeneralAvailabilityWarning
70-
assert user_warning.message.args[0].startswith(
71-
"This API is in beta and is subject to change."
72-
)
67+
with pytest.warns(
68+
GeneralAvailabilityWarning,
69+
match="This API is in beta and is subject to change.",
70+
):
71+
func_beta()
7372

7473
def test_experimental(self, recwarn):
7574

7675
@_stability_warning(stability=Stability.EXPERIMENTAL)
7776
def func_experimental(*args, **kwargs):
7877
pass
7978

80-
func_experimental()
81-
82-
assert len(recwarn) == 1
83-
user_warning = recwarn.pop(GeneralAvailabilityWarning)
84-
assert user_warning.category == GeneralAvailabilityWarning
85-
assert user_warning.message.args[0].startswith(
86-
"This API is in technical preview and may be changed or removed in a future release."
87-
)
88-
89-
def test_deprecated(self, recwarn):
90-
91-
@_stability_warning(
92-
stability=Stability.DEPRECATED, version="8.4.0", message="Use bar instead."
93-
)
94-
def func_deprecated(*args, **kwargs):
95-
pass
96-
97-
func_deprecated()
98-
99-
assert len(recwarn) == 1
100-
user_warning = recwarn.pop(DeprecationWarning)
101-
assert user_warning.category == DeprecationWarning
102-
assert user_warning.message.args[0] == (
103-
"This API was deprecated in Elasticsearch 8.4.0. Use bar instead."
104-
)
79+
with pytest.warns(
80+
GeneralAvailabilityWarning,
81+
match="This API is in technical preview and may be changed or removed in a future release.",
82+
):
83+
func_experimental()

0 commit comments

Comments
 (0)