Minor fixes for pypy tests
This commit is contained in:
@@ -229,7 +229,7 @@ class BoundStatement(Statement):
|
||||
|
||||
try:
|
||||
self.values.append(col_type.serialize(value))
|
||||
except struct.error:
|
||||
except (TypeError, struct.error):
|
||||
col_name = col_spec[2]
|
||||
expected_type = col_type
|
||||
actual_type = type(value)
|
||||
|
@@ -19,8 +19,9 @@ from cassandra.marshal import uint8_pack, uint32_pack
|
||||
|
||||
try:
|
||||
from cassandra.io.libevreactor import LibevConnection
|
||||
except ImportError as exc:
|
||||
raise unittest.SkipTest('libev does not appear to be installed correctly: %s' % (exc,))
|
||||
except ImportError:
|
||||
LibevConnection = None # noqa
|
||||
|
||||
|
||||
@patch('socket.socket')
|
||||
@patch('cassandra.io.libevwrapper.IO')
|
||||
@@ -29,6 +30,10 @@ except ImportError as exc:
|
||||
@patch('cassandra.io.libevreactor._start_loop')
|
||||
class LibevConnectionTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
if LibevConnection is None:
|
||||
raise unittest.SkipTest('libev does not appear to be installed correctly')
|
||||
|
||||
def make_connection(self):
|
||||
c = LibevConnection('1.2.3.4')
|
||||
c._socket = Mock()
|
||||
|
@@ -8,7 +8,11 @@ from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from uuid import UUID
|
||||
|
||||
from blist import sortedset
|
||||
try:
|
||||
from blist import sortedset
|
||||
except ImportError:
|
||||
sortedset = set
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError: # Python <2.7
|
||||
@@ -85,6 +89,7 @@ if platform.python_implementation() == 'CPython':
|
||||
# CPython
|
||||
marshalled_value_pairs += marshalled_value_pairs_unsafe
|
||||
|
||||
|
||||
class TestUnmarshal(unittest.TestCase):
|
||||
def test_unmarshalling(self):
|
||||
for serializedval, valtype, nativeval in marshalled_value_pairs:
|
||||
|
@@ -7,7 +7,7 @@ import cassandra
|
||||
from cassandra.metadata import (TableMetadata, Murmur3Token, MD5Token,
|
||||
BytesToken, ReplicationStrategy,
|
||||
NetworkTopologyStrategy, SimpleStrategy,
|
||||
LocalStrategy)
|
||||
LocalStrategy, NoMurmur3)
|
||||
from cassandra.policies import SimpleConvictionPolicy
|
||||
from cassandra.pool import Host
|
||||
|
||||
@@ -203,22 +203,22 @@ class TestTokens(unittest.TestCase):
|
||||
for keyword in non_valid_keywords:
|
||||
self.assertEqual(table_metadata.is_valid_name(keyword), False)
|
||||
|
||||
def test_token_values(self):
|
||||
"""
|
||||
Spot check token classes and values
|
||||
"""
|
||||
|
||||
# spot check murmur3
|
||||
murmur3_token = Murmur3Token(cassandra.metadata.MIN_LONG - 1)
|
||||
self.assertEqual(murmur3_token.hash_fn('123'), -7468325962851647638)
|
||||
self.assertEqual(murmur3_token.hash_fn(str(cassandra.metadata.MAX_LONG)), 7162290910810015547)
|
||||
self.assertEqual(str(murmur3_token), '<Murmur3Token: -9223372036854775809L>')
|
||||
def test_murmur3_tokens(self):
|
||||
try:
|
||||
murmur3_token = Murmur3Token(cassandra.metadata.MIN_LONG - 1)
|
||||
self.assertEqual(murmur3_token.hash_fn('123'), -7468325962851647638)
|
||||
self.assertEqual(murmur3_token.hash_fn(str(cassandra.metadata.MAX_LONG)), 7162290910810015547)
|
||||
self.assertEqual(str(murmur3_token), '<Murmur3Token: -9223372036854775809L>')
|
||||
except NoMurmur3:
|
||||
raise unittest.SkipTest('The murmur3 extension is not available')
|
||||
|
||||
def test_md5_tokens(self):
|
||||
md5_token = MD5Token(cassandra.metadata.MIN_LONG - 1)
|
||||
self.assertEqual(md5_token.hash_fn('123'), 42767516990368493138776584305024125808L)
|
||||
self.assertEqual(md5_token.hash_fn(str(cassandra.metadata.MAX_LONG)), 28528976619278518853815276204542453639L)
|
||||
self.assertEqual(str(md5_token), '<MD5Token: -9223372036854775809L>')
|
||||
|
||||
def test_bytes_tokens(self):
|
||||
bytes_token = BytesToken(str(cassandra.metadata.MIN_LONG - 1))
|
||||
self.assertEqual(bytes_token.hash_fn('123'), '123')
|
||||
self.assertEqual(bytes_token.hash_fn(123), 123)
|
||||
|
Reference in New Issue
Block a user