示例#1
0
def test_public_static_property():
    """Test public static properties."""
    ob = PropertyTest()

    assert PropertyTest.PublicStaticProperty == 0
    PropertyTest.PublicStaticProperty = 1
    assert PropertyTest.PublicStaticProperty == 1

    assert ob.PublicStaticProperty == 1
    ob.PublicStaticProperty = 0
    assert ob.PublicStaticProperty == 0

    with pytest.raises(TypeError):
        del PropertyTest.PublicStaticProperty

    with pytest.raises(TypeError):
        del PropertyTest().PublicStaticProperty
示例#2
0
    def test_public_static_property(self):
        """Test public static properties."""
        ob = PropertyTest()

        self.assertTrue(PropertyTest.PublicStaticProperty == 0)
        PropertyTest.PublicStaticProperty = 1
        self.assertTrue(PropertyTest.PublicStaticProperty == 1)

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

        with self.assertRaises(TypeError):
            del PropertyTest.PublicStaticProperty

        with self.assertRaises(TypeError):
            del PropertyTest().PublicStaticProperty
示例#3
0
def test_public_static_property():
    """Test public static properties."""
    ob = PropertyTest()

    assert PropertyTest.PublicStaticProperty == 0
    PropertyTest.PublicStaticProperty = 1
    assert PropertyTest.PublicStaticProperty == 1

    assert ob.PublicStaticProperty == 1
    ob.PublicStaticProperty = 0
    assert ob.PublicStaticProperty == 0

    with pytest.raises(TypeError):
        del PropertyTest.PublicStaticProperty

    with pytest.raises(TypeError):
        del PropertyTest().PublicStaticProperty
示例#4
0
    def testPublicStaticProperty(self):
        """Test public static properties."""
        object = PropertyTest()

        self.failUnless(PropertyTest.PublicStaticProperty == 0)
        PropertyTest.PublicStaticProperty = 1
        self.failUnless(PropertyTest.PublicStaticProperty == 1)

        self.failUnless(object.PublicStaticProperty == 1)
        object.PublicStaticProperty = 0
        self.failUnless(object.PublicStaticProperty == 0)

        def test():
            del PropertyTest.PublicStaticProperty

        self.failUnlessRaises(TypeError, test)

        def test():
            del PropertyTest().PublicStaticProperty

        self.failUnlessRaises(TypeError, test)
示例#5
0
    def testPublicStaticProperty(self):
        """Test public static properties."""
        object = PropertyTest();

        self.failUnless(PropertyTest.PublicStaticProperty == 0)
        PropertyTest.PublicStaticProperty = 1
        self.failUnless(PropertyTest.PublicStaticProperty == 1)

        self.failUnless(object.PublicStaticProperty == 1)
        object.PublicStaticProperty = 0
        self.failUnless(object.PublicStaticProperty == 0)

        def test():
            del PropertyTest.PublicStaticProperty

        self.failUnlessRaises(TypeError, test)

        def test():
            del PropertyTest().PublicStaticProperty

        self.failUnlessRaises(TypeError, test)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
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
示例#10
0
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