示例#1
0
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"
示例#2
0
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
示例#3
0
    def test_public_instance_property(self):
        """Test public instance properties."""
        ob = PropertyTest()

        self.assertTrue(ob.PublicProperty == 0)
        ob.PublicProperty = 1
        self.assertTrue(ob.PublicProperty == 1)

        with self.assertRaises(TypeError):
            del PropertyTest().PublicProperty
示例#4
0
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
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
 def test():
     object = PropertyTest()
     object.PublicProperty = "spam"
示例#9
0
 def test():
     object = PropertyTest()
     object.PublicProperty = "spam"
示例#10
0
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"
示例#11
0
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"