def test_decimal_conversion(self): """Test decimal conversion.""" from System import Decimal max_d = Decimal.Parse("79228162514264337593543950335") min_d = Decimal.Parse("-79228162514264337593543950335") self.assertTrue(Decimal.ToInt64(Decimal(10)) == long(10)) ob = ConversionTest() self.assertTrue(ob.DecimalField == Decimal(0)) ob.DecimalField = Decimal(10) self.assertTrue(ob.DecimalField == Decimal(10)) ob.DecimalField = Decimal.One self.assertTrue(ob.DecimalField == Decimal.One) ob.DecimalField = Decimal.Zero self.assertTrue(ob.DecimalField == Decimal.Zero) ob.DecimalField = max_d self.assertTrue(ob.DecimalField == max_d) ob.DecimalField = min_d self.assertTrue(ob.DecimalField == min_d) with self.assertRaises(TypeError): ConversionTest().DecimalField = None with self.assertRaises(TypeError): ConversionTest().DecimalField = "spam" with self.assertRaises(TypeError): ConversionTest().DecimalField = 1
def test_decimal_conversion(): """Test decimal conversion.""" from System import Decimal max_d = Decimal.Parse("79228162514264337593543950335") min_d = Decimal.Parse("-79228162514264337593543950335") assert Decimal.ToInt64(Decimal(10)) == 10 ob = ConversionTest() assert ob.DecimalField == Decimal(0) ob.DecimalField = Decimal(10) assert ob.DecimalField == Decimal(10) ob.DecimalField = Decimal.One assert ob.DecimalField == Decimal.One ob.DecimalField = Decimal.Zero assert ob.DecimalField == Decimal.Zero ob.DecimalField = max_d assert ob.DecimalField == max_d ob.DecimalField = min_d assert ob.DecimalField == min_d with pytest.raises(TypeError): ConversionTest().DecimalField = None with pytest.raises(TypeError): ConversionTest().DecimalField = "spam" with pytest.raises(TypeError): ConversionTest().DecimalField = 1
def test_decimal_conversion(): """Test decimal conversion.""" from System import Decimal max_d = Decimal.Parse("79228162514264337593543950335") min_d = Decimal.Parse("-79228162514264337593543950335") assert Decimal.ToInt64(Decimal(10)) == long(10) ob = ConversionTest() assert ob.DecimalField == Decimal(0) ob.DecimalField = Decimal(10) assert ob.DecimalField == Decimal(10) ob.DecimalField = Decimal.One assert ob.DecimalField == Decimal.One ob.DecimalField = Decimal.Zero assert ob.DecimalField == Decimal.Zero ob.DecimalField = max_d assert ob.DecimalField == max_d ob.DecimalField = min_d assert ob.DecimalField == min_d with pytest.raises(TypeError): ConversionTest().DecimalField = None with pytest.raises(TypeError): ConversionTest().DecimalField = "spam" with pytest.raises(TypeError): ConversionTest().DecimalField = 1
def testDecimalConversion(self): """Test decimal conversion.""" from System import Decimal max_d = Decimal.Parse("79228162514264337593543950335") min_d = Decimal.Parse("-79228162514264337593543950335") self.failUnless(Decimal.ToInt64(Decimal(10)) == 10L) object = ConversionTest() self.failUnless(object.DecimalField == Decimal(0)) object.DecimalField = Decimal(10) self.failUnless(object.DecimalField == Decimal(10)) object.DecimalField = Decimal.One self.failUnless(object.DecimalField == Decimal.One) object.DecimalField = Decimal.Zero self.failUnless(object.DecimalField == Decimal.Zero) object.DecimalField = max_d self.failUnless(object.DecimalField == max_d) object.DecimalField = min_d self.failUnless(object.DecimalField == min_d) def test(): ConversionTest().DecimalField = None self.failUnlessRaises(TypeError, test) def test(): ConversionTest().DecimalField = "spam" self.failUnlessRaises(TypeError, test) def test(): ConversionTest().DecimalField = 1 self.failUnlessRaises(TypeError, test)
def test_decimal_conversion(): """Test decimal conversion.""" from System import Decimal assert Decimal.ToInt64(Decimal(10)) == 10 ob = ConversionTest() assert ob.DecimalField == Decimal(0) ob.DecimalField = Decimal(10) assert ob.DecimalField == Decimal(10) ob.DecimalField = Decimal.One assert ob.DecimalField == Decimal.One ob.DecimalField = Decimal.Zero assert ob.DecimalField == Decimal.Zero with pytest.raises(TypeError): ConversionTest().DecimalField = None with pytest.raises(TypeError): ConversionTest().DecimalField = "spam"