<s> from __future__ import absolute_import , division , print_function <EOL> import sys <EOL> import types <EOL> import warnings <EOL> import pytest <EOL> from cryptography . utils import deprecated <EOL> class TestDeprecated ( object ) : <EOL> def test_deprecated ( self , monkeypatch ) : <EOL> mod = types . ModuleType ( "<STR_LIT>" ) <EOL> monkeypatch . setitem ( sys . modules , mod . __name__ , mod ) <EOL> mod . X = deprecated ( <EOL> value = <NUM_LIT:1> , <EOL> module_name = mod . __name__ , <EOL> message = "<STR_LIT>" , <EOL> warning_class = DeprecationWarning <EOL> ) <EOL> mod . Y = deprecated ( <EOL> value = <NUM_LIT:2> , <EOL> module_name = mod . __name__ , <EOL> message = "<STR_LIT>" , <EOL> warning_class = PendingDeprecationWarning , <EOL> ) <EOL> mod = sys . modules [ mod . __name__ ] <EOL> mod . Z = <NUM_LIT:3> <EOL> with warnings . catch_warnings ( record = True ) as log : <EOL> warnings . simplefilter ( "<STR_LIT>" , PendingDeprecationWarning ) <EOL> warnings . simplefilter ( "<STR_LIT>" , DeprecationWarning ) <EOL> assert mod . X == <NUM_LIT:1> <EOL> assert mod . Y == <NUM_LIT:2> <EOL> assert mod . Z == <NUM_LIT:3> <EOL> [ msg1 , msg2 ] = log <EOL> assert msg1 . category is DeprecationWarning <EOL> assert msg1 . message . args == ( "<STR_LIT>" , ) <EOL> assert msg2 . category is PendingDeprecationWarning <EOL> assert msg2 . message . args == ( "<STR_LIT>" , ) <EOL> assert "<STR_LIT:Y>" in dir ( mod ) <EOL> def test_deleting_deprecated_members ( self , monkeypatch ) : <EOL> mod = types . ModuleType ( "<STR_LIT>" ) <EOL> monkeypatch . setitem ( sys . modules , mod . __name__ , mod ) <EOL> mod . X = deprecated ( <EOL> value = <NUM_LIT:1> , <EOL> module_name = mod . __name__ , <EOL> message = "<STR_LIT>" , <EOL> warning_class = DeprecationWarning <EOL> ) <EOL> mod . Y = deprecated ( <EOL> value = <NUM_LIT:2> , <EOL> module_name = mod . __name__ , <EOL> message = "<STR_LIT>" , <EOL> warning_class = PendingDeprecationWarning , <EOL> ) <EOL> mod = sys . modules [ mod . __name__ ] <EOL> mod . Z = <NUM_LIT:3> <EOL> with warnings . catch_warnings ( record = True ) as log : <EOL> warnings . simplefilter ( "<STR_LIT>" , PendingDeprecationWarning ) <EOL> warnings . simplefilter ( "<STR_LIT>" , DeprecationWarning ) <EOL> del mod . X <EOL> del mod . Y <EOL> del mod . Z <EOL> [ msg1 , msg2 ] = log <EOL> assert msg1 . category is DeprecationWarning <EOL> assert msg1 . message . args == ( "<STR_LIT>" , ) <EOL> assert msg2 . category is PendingDeprecationWarning <EOL> assert msg2 . message . args == ( "<STR_LIT>" , ) <EOL> assert "<STR_LIT:X>" not in dir ( mod ) <EOL> assert "<STR_LIT:Y>" not in dir ( mod ) <EOL> assert "<STR_LIT>" not in dir ( mod ) <EOL> with pytest . raises ( AttributeError ) : <EOL> del mod . X </s>
