Don't test Decimal(float) for python 2.6
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import sys
|
||||
|
||||
from cassandra.marshal import bitlength
|
||||
from cassandra.protocol import MAX_SUPPORTED_VERSION
|
||||
|
||||
@@ -25,7 +27,7 @@ from decimal import Decimal
|
||||
from uuid import UUID
|
||||
|
||||
from cassandra.cqltypes import lookup_casstype, DecimalType, UTF8Type, DateType
|
||||
from cassandra.util import OrderedMap, OrderedMapSerializedKey, sortedset, Time, Date
|
||||
from cassandra.util import OrderedMapSerializedKey, sortedset, Time, Date
|
||||
|
||||
marshalled_value_pairs = (
|
||||
# binary form, type, python native type
|
||||
@@ -143,8 +145,18 @@ class UnmarshalTest(unittest.TestCase):
|
||||
|
||||
def test_decimal(self):
|
||||
# testing implicit numeric conversion
|
||||
# int, float, tuple(sign, digits, exp)
|
||||
# int, tuple(sign, digits, exp), float
|
||||
converted_types = (10001, (0, (1, 0, 0, 0, 0, 1), -3), 100.1)
|
||||
|
||||
if sys.version_info < (2, 7):
|
||||
# Decimal in Python 2.6 does not accept floats for lossless initialization
|
||||
# Just verifying expected exception here
|
||||
f = converted_types[-1]
|
||||
self.assertIsInstance(f, float)
|
||||
self.assertRaises(TypeError, DecimalType.to_binary, f, MAX_SUPPORTED_VERSION)
|
||||
converted_types = converted_types[:-1]
|
||||
|
||||
for proto_ver in range(1, MAX_SUPPORTED_VERSION + 1):
|
||||
for n in (10001, 100.1, (0, (1, 0, 0, 0, 0, 1), -3)):
|
||||
for n in converted_types:
|
||||
expected = Decimal(n)
|
||||
self.assertEqual(DecimalType.from_binary(DecimalType.to_binary(n, proto_ver), proto_ver), expected)
|
||||
|
||||
Reference in New Issue
Block a user