Ejemplo n.º 1
0
def test_read_only_instance_field():
    """Test readonly instance fields."""
    assert FieldTest().ReadOnlyField == 0

    with pytest.raises(TypeError):
        FieldTest().ReadOnlyField = 1

    with pytest.raises(TypeError):
        del FieldTest().ReadOnlyField
Ejemplo n.º 2
0
def test_protected_instance_field():
    """Test protected instance fields."""
    ob = FieldTest()
    assert ob.ProtectedField == 0

    ob.ProtectedField = 1
    assert ob.ProtectedField == 1

    with pytest.raises(TypeError):
        del FieldTest().ProtectedField
Ejemplo n.º 3
0
def test_public_instance_field():
    """Test public instance fields."""
    ob = FieldTest()
    assert ob.PublicField == 0

    ob.PublicField = 1
    assert ob.PublicField == 1

    with pytest.raises(TypeError):
        del FieldTest().PublicField
Ejemplo n.º 4
0
def test_private_field():
    """Test private fields."""

    with pytest.raises(AttributeError):
        _ = FieldTest().PrivateField

    with pytest.raises(AttributeError):
        _ = FieldTest().PrivateStaticField

    with pytest.raises(AttributeError):
        _ = FieldTest.PrivateStaticField
Ejemplo n.º 5
0
def test_internal_field():
    """Test internal fields."""

    with pytest.raises(AttributeError):
        _ = FieldTest().InternalField

    with pytest.raises(AttributeError):
        _ = FieldTest().InternalStaticField

    with pytest.raises(AttributeError):
        _ = FieldTest.InternalStaticField
Ejemplo n.º 6
0
    def testEnumField(self):
        """Test enum fields."""
        object = FieldTest()
        self.failUnless(object.EnumField == ShortEnum.Zero)

        object.EnumField = ShortEnum.One
        self.failUnless(object.EnumField == ShortEnum.One)
Ejemplo n.º 7
0
    def testDecimalField(self):
        """Test decimal fields."""
        object = FieldTest()
        self.assertTrue(object.DecimalField == System.Decimal(0))

        object.DecimalField = System.Decimal(1)
        self.assertTrue(object.DecimalField == System.Decimal(1))
Ejemplo n.º 8
0
def test_string_field():
    """Test string fields."""
    ob = FieldTest()
    assert ob.StringField == "spam"

    ob.StringField = "eggs"
    assert ob.StringField == "eggs"
Ejemplo n.º 9
0
def test_double_field():
    """Test double fields."""
    ob = FieldTest()
    assert ob.DoubleField == 0.0

    ob.DoubleField = 1.1
    assert ob.DoubleField == 1.1
Ejemplo n.º 10
0
def test_uint64_field():
    """Test uint64 fields."""
    ob = FieldTest()
    assert ob.UInt64Field == 0

    ob.UInt64Field = 1
    assert ob.UInt64Field == 1
Ejemplo n.º 11
0
def test_uint16_field():
    """Test uint16 fields."""
    ob = FieldTest()
    assert ob.UInt16Field == 0

    ob.UInt16Field = 1
    assert ob.UInt16Field == 1
Ejemplo n.º 12
0
    def testInt32Field(self):
        """Test int32 fields."""
        object = FieldTest()
        self.failUnless(object.Int32Field == 0)

        object.Int32Field = 1
        self.failUnless(object.Int32Field == 1)
Ejemplo n.º 13
0
    def testByteField(self):
        """Test byte fields."""
        object = FieldTest()
        self.failUnless(object.ByteField == 0)

        object.ByteField = 1
        self.failUnless(object.ByteField == 1)
Ejemplo n.º 14
0
    def testConstantField(self):
        """Test const fields."""
        object = FieldTest()

        self.failUnless(FieldTest.ConstField == 0)
        self.failUnless(object.ConstField == 0)

        def test():
            FieldTest().ConstField = 1

        self.failUnlessRaises(TypeError, test)

        def test():
            FieldTest.ConstField = 1

        self.failUnlessRaises(TypeError, test)

        def test():
            del FieldTest().ConstField

        self.failUnlessRaises(TypeError, test)

        def test():
            del FieldTest.ConstField

        self.failUnlessRaises(TypeError, test)
Ejemplo n.º 15
0
    def testReadOnlyStaticField(self):
        """Test readonly static fields."""
        object = FieldTest()

        self.failUnless(FieldTest.ReadOnlyStaticField == 0)
        self.failUnless(object.ReadOnlyStaticField == 0)

        def test():
            FieldTest.ReadOnlyStaticField = 1

        self.failUnlessRaises(TypeError, test)

        def test():
            FieldTest().ReadOnlyStaticField = 1

        self.failUnlessRaises(TypeError, test)

        def test():
            del FieldTest.ReadOnlyStaticField

        self.failUnlessRaises(TypeError, test)

        def test():
            del FieldTest().ReadOnlyStaticField

        self.failUnlessRaises(TypeError, test)
Ejemplo n.º 16
0
    def testEnumField(self):
        """Test enum fields."""
        object = FieldTest()
        self.assertTrue(object.EnumField == ShortEnum.Zero)

        object.EnumField = ShortEnum.One
        self.assertTrue(object.EnumField == ShortEnum.One)
Ejemplo n.º 17
0
    def testStringField(self):
        """Test string fields."""
        object = FieldTest()
        self.assertTrue(object.StringField == "spam")

        object.StringField = "eggs"
        self.assertTrue(object.StringField == "eggs")
Ejemplo n.º 18
0
    def testUInt64Field(self):
        """Test uint64 fields."""
        object = FieldTest()
        self.failUnless(object.UInt64Field == 0)

        object.UInt64Field = 1
        self.failUnless(object.UInt64Field == 1)
Ejemplo n.º 19
0
def test_byte_field():
    """Test byte fields."""
    ob = FieldTest()
    assert ob.ByteField == 0

    ob.ByteField = 1
    assert ob.ByteField == 1
Ejemplo n.º 20
0
    def testSingleField(self):
        """Test single fields."""
        object = FieldTest()
        self.failUnless(object.SingleField == 0.0)

        object.SingleField = 1.1
        self.failUnless(object.SingleField == 1.1)
Ejemplo n.º 21
0
def test_uint32_field():
    """Test uint32 fields."""
    ob = FieldTest()
    assert ob.UInt32Field == 0

    ob.UInt32Field = 1
    assert ob.UInt32Field == 1
Ejemplo n.º 22
0
    def testDoubleField(self):
        """Test double fields."""
        object = FieldTest()
        self.failUnless(object.DoubleField == 0.0)

        object.DoubleField = 1.1
        self.failUnless(object.DoubleField == 1.1)
Ejemplo n.º 23
0
def test_single_field():
    """Test single fields."""
    ob = FieldTest()
    assert ob.SingleField == 0.0

    ob.SingleField = 1.1
    assert ob.SingleField == 1.1
Ejemplo n.º 24
0
    def testSingleField(self):
        """Test single fields."""
        object = FieldTest()
        self.assertTrue(object.SingleField == 0.0)

        object.SingleField = 1.1
        self.assertTrue(object.SingleField == 1.1)
Ejemplo n.º 25
0
def test_decimal_field():
    """Test decimal fields."""
    ob = FieldTest()
    assert ob.DecimalField == System.Decimal(0)

    ob.DecimalField = System.Decimal(1)
    assert ob.DecimalField == System.Decimal(1)
Ejemplo n.º 26
0
    def testUInt64Field(self):
        """Test uint64 fields."""
        object = FieldTest()
        self.assertTrue(object.UInt64Field == 0)

        object.UInt64Field = 1
        self.assertTrue(object.UInt64Field == 1)
Ejemplo n.º 27
0
    def testDecimalField(self):
        """Test decimal fields."""
        object = FieldTest()
        self.failUnless(object.DecimalField == System.Decimal(0))

        object.DecimalField = System.Decimal(1)
        self.failUnless(object.DecimalField == System.Decimal(1))
Ejemplo n.º 28
0
    def testDoubleField(self):
        """Test double fields."""
        object = FieldTest()
        self.assertTrue(object.DoubleField == 0.0)

        object.DoubleField = 1.1
        self.assertTrue(object.DoubleField == 1.1)
Ejemplo n.º 29
0
    def testStringField(self):
        """Test string fields."""
        object = FieldTest()
        self.failUnless(object.StringField == "spam")

        object.StringField = "eggs"
        self.failUnless(object.StringField == "eggs")
Ejemplo n.º 30
0
    def testInt32Field(self):
        """Test int32 fields."""
        object = FieldTest()
        self.assertTrue(object.Int32Field == 0)

        object.Int32Field = 1
        self.assertTrue(object.Int32Field == 1)