def test_property_descriptor_wrong_type(): """Test setting a property using a value of the wrong type.""" # Will attempt to implicitly convert "spam" to int, and fail, resulting in ValueError with pytest.raises(ValueError): ob = PropertyTest() ob.PublicProperty = "spam"
def test_protected_instance_property(): """Test protected instance properties.""" ob = PropertyTest() assert ob.ProtectedProperty == 0 ob.ProtectedProperty = 1 assert ob.ProtectedProperty == 1 with pytest.raises(TypeError): del PropertyTest().ProtectedProperty
def test_protected_instance_property(self): """Test protected instance properties.""" ob = PropertyTest() self.assertTrue(ob.ProtectedProperty == 0) ob.ProtectedProperty = 1 self.assertTrue(ob.ProtectedProperty == 1) with self.assertRaises(TypeError): del PropertyTest().ProtectedProperty
def test_public_instance_property(): """Test public instance properties.""" ob = PropertyTest() assert ob.PublicProperty == 0 ob.PublicProperty = 1 assert ob.PublicProperty == 1 with pytest.raises(TypeError): del PropertyTest().PublicProperty
def test_private_property(): """Test private properties.""" with pytest.raises(AttributeError): _ = PropertyTest().PrivateProperty with pytest.raises(AttributeError): _ = PropertyTest().PrivateStaticProperty with pytest.raises(AttributeError): _ = PropertyTest.PrivateStaticProperty
def test_internal_property(): """Test internal properties.""" with pytest.raises(AttributeError): _ = PropertyTest().InternalProperty with pytest.raises(AttributeError): _ = PropertyTest().InternalStaticProperty with pytest.raises(AttributeError): _ = PropertyTest.InternalStaticProperty
def testPublicInstanceProperty(self): """Test public instance properties.""" object = PropertyTest() self.failUnless(object.PublicProperty == 0) object.PublicProperty = 1 self.failUnless(object.PublicProperty == 1) def test(): del PropertyTest().PublicProperty self.failUnlessRaises(TypeError, test)
def testPublicInstanceProperty(self): """Test public instance properties.""" object = PropertyTest() self.assertTrue(object.PublicProperty == 0) object.PublicProperty = 1 self.assertTrue(object.PublicProperty == 1) def test(): del PropertyTest().PublicProperty self.assertRaises(TypeError, test)
def testProtectedInstanceProperty(self): """Test protected instance properties.""" object = PropertyTest() self.failUnless(object.ProtectedProperty == 0) object.ProtectedProperty = 1 self.failUnless(object.ProtectedProperty == 1) def test(): del PropertyTest().ProtectedProperty self.failUnlessRaises(TypeError, test)
def testPublicInstanceProperty(self): """Test public instance properties.""" object = PropertyTest(); self.assertTrue(object.PublicProperty == 0) object.PublicProperty = 1 self.assertTrue(object.PublicProperty == 1) def test(): del PropertyTest().PublicProperty self.assertRaises(TypeError, test)
def testProtectedInstanceProperty(self): """Test protected instance properties.""" object = PropertyTest(); self.assertTrue(object.ProtectedProperty == 0) object.ProtectedProperty = 1 self.assertTrue(object.ProtectedProperty == 1) def test(): del PropertyTest().ProtectedProperty self.assertRaises(TypeError, test)
def testProtectedInstanceProperty(self): """Test protected instance properties.""" object = PropertyTest(); self.failUnless(object.ProtectedProperty == 0) object.ProtectedProperty = 1 self.failUnless(object.ProtectedProperty == 1) def test(): del PropertyTest().ProtectedProperty self.failUnlessRaises(TypeError, test)
def test_protected_static_property(): """Test protected static properties.""" ob = PropertyTest() assert PropertyTest.ProtectedStaticProperty == 0 PropertyTest.ProtectedStaticProperty = 1 assert PropertyTest.ProtectedStaticProperty == 1 assert ob.ProtectedStaticProperty == 1 ob.ProtectedStaticProperty = 0 assert ob.ProtectedStaticProperty == 0 with pytest.raises(TypeError): del PropertyTest.ProtectedStaticProperty with pytest.raises(TypeError): del PropertyTest().ProtectedStaticProperty
def test_protected_static_property(self): """Test protected static properties.""" ob = PropertyTest() self.assertTrue(PropertyTest.ProtectedStaticProperty == 0) PropertyTest.ProtectedStaticProperty = 1 self.assertTrue(PropertyTest.ProtectedStaticProperty == 1) self.assertTrue(ob.ProtectedStaticProperty == 1) ob.ProtectedStaticProperty = 0 self.assertTrue(ob.ProtectedStaticProperty == 0) with self.assertRaises(TypeError): del PropertyTest.ProtectedStaticProperty with self.assertRaises(TypeError): del PropertyTest().ProtectedStaticProperty
def testPublicStaticProperty(self): """Test public static properties.""" object = PropertyTest(); self.assertTrue(PropertyTest.PublicStaticProperty == 0) PropertyTest.PublicStaticProperty = 1 self.assertTrue(PropertyTest.PublicStaticProperty == 1) self.assertTrue(object.PublicStaticProperty == 1) object.PublicStaticProperty = 0 self.assertTrue(object.PublicStaticProperty == 0) def test(): del PropertyTest.PublicStaticProperty self.assertRaises(TypeError, test) def test(): del PropertyTest().PublicStaticProperty self.assertRaises(TypeError, test)
def testProtectedStaticProperty(self): """Test protected static properties.""" object = PropertyTest(); self.failUnless(PropertyTest.ProtectedStaticProperty == 0) PropertyTest.ProtectedStaticProperty = 1 self.failUnless(PropertyTest.ProtectedStaticProperty == 1) self.failUnless(object.ProtectedStaticProperty == 1) object.ProtectedStaticProperty = 0 self.failUnless(object.ProtectedStaticProperty == 0) def test(): del PropertyTest.ProtectedStaticProperty self.failUnlessRaises(TypeError, test) def test(): del PropertyTest().ProtectedStaticProperty self.failUnlessRaises(TypeError, test)
def testProtectedStaticProperty(self): """Test protected static properties.""" object = PropertyTest() self.failUnless(PropertyTest.ProtectedStaticProperty == 0) PropertyTest.ProtectedStaticProperty = 1 self.failUnless(PropertyTest.ProtectedStaticProperty == 1) self.failUnless(object.ProtectedStaticProperty == 1) object.ProtectedStaticProperty = 0 self.failUnless(object.ProtectedStaticProperty == 0) def test(): del PropertyTest.ProtectedStaticProperty self.failUnlessRaises(TypeError, test) def test(): del PropertyTest().ProtectedStaticProperty self.failUnlessRaises(TypeError, test)
def testPublicStaticProperty(self): """Test public static properties.""" object = PropertyTest() self.assertTrue(PropertyTest.PublicStaticProperty == 0) PropertyTest.PublicStaticProperty = 1 self.assertTrue(PropertyTest.PublicStaticProperty == 1) self.assertTrue(object.PublicStaticProperty == 1) object.PublicStaticProperty = 0 self.assertTrue(object.PublicStaticProperty == 0) def test(): del PropertyTest.PublicStaticProperty self.assertRaises(TypeError, test) def test(): del PropertyTest().PublicStaticProperty self.assertRaises(TypeError, test)
def test_property_descriptor_get_set(): """Test property descriptor get / set.""" # This test ensures that setting an attribute implemented with # a descriptor actually goes through the descriptor (rather than # silently replacing the descriptor in the instance or type dict. ob = PropertyTest() assert PropertyTest.PublicStaticProperty == 0 assert ob.PublicStaticProperty == 0 descriptor = PropertyTest.__dict__['PublicStaticProperty'] assert type(descriptor) != int ob.PublicStaticProperty = 0 descriptor = PropertyTest.__dict__['PublicStaticProperty'] assert type(descriptor) != int PropertyTest.PublicStaticProperty = 0 descriptor = PropertyTest.__dict__['PublicStaticProperty'] assert type(descriptor) != int
def testPropertyDescriptorGetSet(self): """Test property descriptor get / set.""" # This test ensures that setting an attribute implemented with # a descriptor actually goes through the descriptor (rather than # silently replacing the descriptor in the instance or type dict. object = PropertyTest() self.failUnless(PropertyTest.PublicStaticProperty == 0) self.failUnless(object.PublicStaticProperty == 0) descriptor = PropertyTest.__dict__['PublicStaticProperty'] self.failUnless(type(descriptor) != types.IntType) object.PublicStaticProperty = 0 descriptor = PropertyTest.__dict__['PublicStaticProperty'] self.failUnless(type(descriptor) != types.IntType) PropertyTest.PublicStaticProperty = 0 descriptor = PropertyTest.__dict__['PublicStaticProperty'] self.failUnless(type(descriptor) != types.IntType)
def test(): del PropertyTest().ProtectedStaticProperty
def test(): del PropertyTest().ProtectedProperty
def test(): del PropertyTest().PublicStaticProperty
def test(): object = PropertyTest() object.PublicProperty = "spam"
def test(): f = PropertyTest().PrivateStaticProperty
def test(): f = PropertyTest().PrivateProperty
def test_property_descriptor_wrong_type(): """Test setting a property using a value of the wrong type.""" with pytest.raises(TypeError): ob = PropertyTest() ob.PublicProperty = "spam"
def test(): f = PropertyTest().InternalProperty
def test(): f = PropertyTest().InternalStaticProperty