def test_valid_decimal_strings(self): # Ensures that decimal.Decimal doesn't cause a valid string to become # invalid valid_str = '-9.81338674e-006' ds = valuerep.DS(valid_str) assert len(str(ds)) <= 16 # Now the input string is too long but decimal.Decimal can convert it # to a valid 16-character string long_str = '-0.000000981338674' ds = valuerep.DS(long_str) assert len(str(ds)) <= 16
def testValidDecimalStrings(self): # Ensures that decimal.Decimal doesn't cause a valid string to become # invalid valid_str = '-9.81338674e-006' ds = valuerep.DS(valid_str) L = len(str(ds)) self.assertTrue(L <= 16, "DS: expected a string of length 16 but got %d" % (L,)) # noqa # Now the input string is too long but decimal.Decimal can convert it # to a valid 16-character string long_str = '-0.000000981338674' ds = valuerep.DS(long_str) L = len(str(ds)) self.assertTrue(L <= 16, "DS: expected a string of length 16 but got %d" % (L,)) # noqa
def test_valid_decimal_strings(self): # Ensures that decimal.Decimal doesn't cause a valid string to become # invalid valid_str = "-9.81338674e-006" ds = valuerep.DS(valid_str) assert isinstance(ds, valuerep.DSdecimal) assert len(str(ds)) <= 16
def test_invalid_decimal_strings(self, enforce_valid_values): # Now the input string truly is invalid invalid_string = "-9.813386743e-006" with pytest.raises(OverflowError): valuerep.DS(invalid_string)