Exemple #1
0
    def test_char_conversion(self):
        """Test char conversion."""
        self.assertTrue(System.Char.MaxValue == unichr(65535))
        self.assertTrue(System.Char.MinValue == unichr(0))

        ob = ConversionTest()
        self.assertTrue(ob.CharField == u'A')

        ob.CharField = 'B'
        self.assertTrue(ob.CharField == u'B')

        ob.CharField = u'B'
        self.assertTrue(ob.CharField == u'B')

        ob.CharField = 67
        self.assertTrue(ob.CharField == u'C')

        with self.assertRaises(OverflowError):
            ConversionTest().CharField = 65536

        with self.assertRaises(OverflowError):
            ConversionTest().CharField = -1

        with self.assertRaises(TypeError):
            ConversionTest().CharField = None
def test_char_conversion():
    """Test char conversion."""
    assert System.Char.MaxValue == chr(65535)
    assert System.Char.MinValue == chr(0)

    ob = ConversionTest()
    assert ob.CharField == u'A'

    ob.CharField = 'B'
    assert ob.CharField == u'B'

    ob.CharField = u'B'
    assert ob.CharField == u'B'

    ob.CharField = 67
    assert ob.CharField == u'C'

    with pytest.raises(OverflowError):
        ConversionTest().CharField = 65536

    with pytest.raises(OverflowError):
        ConversionTest().CharField = -1

    with pytest.raises(TypeError):
        ConversionTest().CharField = None
    def testCharConversion(self):
        """Test char conversion."""
        self.assertTrue(System.Char.MaxValue == unichr(65535))
        self.assertTrue(System.Char.MinValue == unichr(0))

        object = ConversionTest()
        self.assertTrue(object.CharField == six.u('A'))

        object.CharField = 'B'
        self.assertTrue(object.CharField == six.u('B'))

        object.CharField = six.u('B')
        self.assertTrue(object.CharField == six.u('B'))

        object.CharField = 67
        self.assertTrue(object.CharField == six.u('C'))

        def test():
            ConversionTest().CharField = 65536

        self.assertRaises(OverflowError, test)

        def test():
            ConversionTest().CharField = -1

        self.assertRaises(OverflowError, test)

        def test():
            ConversionTest().CharField = None

        self.assertRaises(TypeError, test)
    def testCharConversion(self):
        """Test char conversion."""
        self.failUnless(System.Char.MaxValue == unichr(65535))
        self.failUnless(System.Char.MinValue == unichr(0))

        object = ConversionTest()
        self.failUnless(object.CharField == u'A')

        object.CharField = 'B'
        self.failUnless(object.CharField == u'B')

        object.CharField = u'B'
        self.failUnless(object.CharField == u'B')

        object.CharField = 67
        self.failUnless(object.CharField == u'C')

        def test():
            ConversionTest().CharField = 65536
            
        self.failUnlessRaises(OverflowError, test)

        def test():
            ConversionTest().CharField = -1
            
        self.failUnlessRaises(OverflowError, test)

        def test():
            ConversionTest().CharField = None

        self.failUnlessRaises(TypeError, test)
    def testCharConversion(self):
        """Test char conversion."""
        self.assertTrue(System.Char.MaxValue == unichr(65535))
        self.assertTrue(System.Char.MinValue == unichr(0))

        object = ConversionTest()
        self.assertTrue(object.CharField == six.u('A'))

        object.CharField = 'B'
        self.assertTrue(object.CharField == six.u('B'))

        object.CharField = six.u('B')
        self.assertTrue(object.CharField == six.u('B'))

        object.CharField = 67
        self.assertTrue(object.CharField == six.u('C'))

        def test():
            ConversionTest().CharField = 65536

        self.assertRaises(OverflowError, test)

        def test():
            ConversionTest().CharField = -1

        self.assertRaises(OverflowError, test)

        def test():
            ConversionTest().CharField = None

        self.assertRaises(TypeError, test)
Exemple #6
0
def test_char_conversion():
    """Test char conversion."""
    assert System.Char.MaxValue == unichr(65535)
    assert System.Char.MinValue == unichr(0)

    ob = ConversionTest()
    assert ob.CharField == u'A'

    ob.CharField = 'B'
    assert ob.CharField == u'B'

    ob.CharField = u'B'
    assert ob.CharField == u'B'

    ob.CharField = 67
    assert ob.CharField == u'C'

    with pytest.raises(OverflowError):
        ConversionTest().CharField = 65536

    with pytest.raises(OverflowError):
        ConversionTest().CharField = -1

    with pytest.raises(TypeError):
        ConversionTest().CharField = None