Skip to content

Commit 7692ff3

Browse files
committed
refactor: Изменена проверка warning для совместимой с 37 версии
1 parent b303bee commit 7692ff3

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/unit/test_client_basics.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import pytest
24

35
import mellophone
@@ -26,14 +28,18 @@ def test_client_options_are_stored():
2628
assert client.timeout == 7.5
2729

2830

29-
def test_client_deprecated_token_aliases_work_and_warn():
30-
with pytest.warns(DeprecationWarning, match="set_settings_token"):
31-
with pytest.warns(DeprecationWarning, match="user_manage_token"):
32-
client = mellophone.Mellophone(
33-
"http://example.com",
34-
set_settings_token="set-token-old",
35-
user_manage_token="user-token-old",
36-
)
31+
def test_client_deprecated_token_aliases():
32+
with warnings.catch_warnings(record=True) as caught:
33+
warnings.simplefilter("always", DeprecationWarning)
34+
client = mellophone.Mellophone(
35+
"http://example.com",
36+
set_settings_token="set-token-old",
37+
user_manage_token="user-token-old",
38+
)
39+
40+
deprecation_messages = [str(item.message) for item in caught if isinstance(item.message, DeprecationWarning)]
41+
assert any("set_settings_token" in message for message in deprecation_messages)
42+
assert any("user_manage_token" in message for message in deprecation_messages)
3743

3844
assert client.token_set_settings == "set-token-old"
3945
assert client.token_user_manage == "user-token-old"

0 commit comments

Comments
 (0)