def test_deprecated_property_delete(): from webob.descriptors import deprecated_property dep = deprecated_property(deprecated_property, 'deprecated_property', 'DEPRECATED', warning=False) assert_raises(DeprecationWarning, dep.__delete__, dep)
def test_deprecated_property_get_none(): from webob.descriptors import deprecated_property dep = deprecated_property(None, 'deprecated_property', 'DEPRECATED', warning=False) eq_(dep.__get__(None), dep)
def test_deprecated_property_ctor_raises(): from webob.descriptors import deprecated_property prop = property() dep = deprecated_property(prop, 'deprecated_property', "Don't use it", warning=False) assert_raises(DeprecationWarning, dep.warn)
def test_deprecated_property_ctor_message(): from webob.descriptors import deprecated_property prop = property() dep = deprecated_property(prop, 'deprecated_property', "Don't use it", warning=False) eq_(dep.message, "Don't use it")
def test_deprecated_property(): from webob.descriptors import deprecated_property class Foo(object): pass Foo.attr = deprecated_property('attr', 'attr', 'whatever', '1.2') foo = Foo() assert_raises(DeprecationWarning, getattr, foo, 'attr') assert_raises(DeprecationWarning, setattr, foo, 'attr', {}) assert_raises(DeprecationWarning, delattr, foo, 'attr')
def test_deprecated_property_warn_delete(): import warnings from webob.descriptors import deprecated_property mock = MockDescriptor() dep = deprecated_property(mock, 'mock_property', 'DEPRECATED') try: warnings.simplefilter('error') assert_raises(DeprecationWarning, dep.__delete__, mock) finally: warnings.resetwarnings()
def test_deprecated_property_warn_get_call(): import warnings from webob.descriptors import deprecated_property mock = MockDescriptor() dep = deprecated_property(mock, 'mock_property', 'DEPRECATED') try: warnings.simplefilter('ignore') eq_(dep.__get__(mock), 'avalue') finally: warnings.resetwarnings()
def test_deprecated_property(): from webob.descriptors import deprecated_property class Foo(object): pass Foo.attr = deprecated_property("attr", "attr", "whatever", "1.2") foo = Foo() assert_raises(DeprecationWarning, getattr, foo, "attr") assert_raises(DeprecationWarning, setattr, foo, "attr", {}) assert_raises(DeprecationWarning, delattr, foo, "attr")
def test_deprecated_property_repr(): import warnings from webob.descriptors import deprecated_property mock = MockDescriptor() try: warnings.simplefilter('ignore') dep = deprecated_property(mock, 'mock_property', 'DEPRECATED') assert dep.__repr__().startswith( "<Deprecated attribute mock_property: " "<tests.test_descriptors.MockDescriptor instance at") finally: warnings.resetwarnings()
def test_deprecated_property(): from webob.descriptors import deprecated_property class Foo(object): pass Foo.attr = deprecated_property('attr', 'attr', 'whatever', '1.2') foo = Foo() with pytest.raises(DeprecationWarning): getattr(foo, 'attr') with pytest.raises(DeprecationWarning): setattr(foo, 'attr', {}) with pytest.raises(DeprecationWarning): delattr(foo, 'attr')
def test_deprecated_property(): from webob.descriptors import deprecated_property class Foo: pass Foo.attr = deprecated_property("attr", "attr", "whatever", "1.2") foo = Foo() with pytest.raises(DeprecationWarning): getattr(foo, "attr") with pytest.raises(DeprecationWarning): setattr(foo, "attr", {}) with pytest.raises(DeprecationWarning): delattr(foo, "attr")
def test_deprecated_property(): from webob.descriptors import deprecated_property class Foo(object): pass Foo.attr = deprecated_property("attr", "attr", "whatever", "1.2") foo = Foo() with pytest.raises(DeprecationWarning): getattr(foo, "attr") with pytest.raises(DeprecationWarning): setattr(foo, "attr", {}) with pytest.raises(DeprecationWarning): delattr(foo, "attr")