2020-09-10 23:34:20 +04:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from aiogram.utils.deprecated import DeprecatedReadOnlyClassVar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_DeprecatedReadOnlyClassVarCD():
|
2020-11-08 21:49:34 +00:00
|
|
|
if DeprecatedReadOnlyClassVar.__slots__ != (
|
|
|
|
|
"_new_value_getter",
|
|
|
|
|
"_warning_message",
|
|
|
|
|
):
|
2020-11-08 21:48:49 +00:00
|
|
|
raise AssertionError
|
2020-09-10 23:34:20 +04:00
|
|
|
|
|
|
|
|
new_value_of_deprecated_cls_cd = "mpa"
|
2020-11-08 21:49:34 +00:00
|
|
|
deprecated_cd = DeprecatedReadOnlyClassVar(
|
|
|
|
|
"mopekaa", lambda owner: new_value_of_deprecated_cls_cd
|
|
|
|
|
)
|
2020-09-10 23:34:20 +04:00
|
|
|
|
|
|
|
|
with pytest.warns(DeprecationWarning):
|
2020-11-04 15:55:25 +00:00
|
|
|
pseudo_owner_cls = type("OpekaCla$$", (), {})
|
2020-11-08 21:49:34 +00:00
|
|
|
if (
|
|
|
|
|
deprecated_cd.__get__(None, pseudo_owner_cls)
|
|
|
|
|
!= new_value_of_deprecated_cls_cd
|
|
|
|
|
):
|
2020-11-08 21:48:49 +00:00
|
|
|
raise AssertionError
|