From 9aaf1ec532f730c9fefd5ba4440553ea75ffa6b3 Mon Sep 17 00:00:00 2001 From: Jim Witschey Date: Fri, 26 May 2017 12:05:32 -0400 Subject: [PATCH] whitespace fixes pre-PYTHON-761 --- cassandra/policies.py | 1 + .../integration/long/test_loadbalancingpolicies.py | 13 ++++++++----- tests/unit/test_policies.py | 10 ++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cassandra/policies.py b/cassandra/policies.py index 389ee353..d078da27 100644 --- a/cassandra/policies.py +++ b/cassandra/policies.py @@ -619,6 +619,7 @@ class WriteType(object): A lighweight-transaction write, such as "DELETE ... IF EXISTS". """ + WriteType.name_to_value = { 'SIMPLE': WriteType.SIMPLE, 'BATCH': WriteType.BATCH, diff --git a/tests/integration/long/test_loadbalancingpolicies.py b/tests/integration/long/test_loadbalancingpolicies.py index 99612480..f16df83f 100644 --- a/tests/integration/long/test_loadbalancingpolicies.py +++ b/tests/integration/long/test_loadbalancingpolicies.py @@ -12,11 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import struct, time, logging, sys, traceback +import logging +import struct +import sys +import traceback from cassandra import ConsistencyLevel, Unavailable, OperationTimedOut, ReadTimeout, ReadFailure, \ WriteTimeout, WriteFailure -from cassandra.cluster import Cluster, NoHostAvailable, ExecutionProfile +from cassandra.cluster import Cluster, NoHostAvailable from cassandra.concurrent import execute_concurrent_with_args from cassandra.metadata import murmur3 from cassandra.policies import (RoundRobinPolicy, DCAwareRoundRobinPolicy, @@ -40,7 +43,7 @@ log = logging.getLogger(__name__) class LoadBalancingPolicyTests(unittest.TestCase): def setUp(self): - remove_cluster() # clear ahead of test so it doesn't use one left in unknown state + remove_cluster() # clear ahead of test so it doesn't use one left in unknown state self.coordinator_stats = CoordinatorStats() self.prepared = None self.probe_cluster = None @@ -105,7 +108,7 @@ class LoadBalancingPolicyTests(unittest.TestCase): query_string = 'SELECT * FROM %s.cf WHERE k = ?' % keyspace if not self.prepared or self.prepared.query_string != query_string: self.prepared = session.prepare(query_string) - self.prepared.consistency_level=consistency_level + self.prepared.consistency_level = consistency_level for i in range(count): tries = 0 while True: @@ -508,7 +511,7 @@ class LoadBalancingPolicyTests(unittest.TestCase): self.coordinator_stats.reset_counts() stop(2) - self._wait_for_nodes_down([2],cluster) + self._wait_for_nodes_down([2], cluster) self._query(session, keyspace) diff --git a/tests/unit/test_policies.py b/tests/unit/test_policies.py index 33f913cc..c66fe532 100644 --- a/tests/unit/test_policies.py +++ b/tests/unit/test_policies.py @@ -421,7 +421,6 @@ class DCAwareRoundRobinPolicyTest(unittest.TestCase): policy.on_up(hosts[2]) policy.on_up(hosts[3]) - another_host = Host(5, SimpleConvictionPolicy) another_host.set_location_info("dc3", "rack1") new_host.set_location_info("dc3", "rack1") @@ -755,7 +754,7 @@ class TokenAwarePolicyTest(unittest.TestCase): @test_category policy """ self._assert_shuffle(keyspace=None, routing_key='routing_key') - + def test_no_shuffle_if_given_no_routing_key(self): """ Test to validate the hosts are not shuffled when no routing_key is provided @@ -766,7 +765,7 @@ class TokenAwarePolicyTest(unittest.TestCase): @test_category policy """ self._assert_shuffle(keyspace='keyspace', routing_key=None) - + @patch('cassandra.policies.shuffle') def _assert_shuffle(self, patched_shuffle, keyspace, routing_key): hosts = [Host(str(i), SimpleConvictionPolicy) for i in range(4)] @@ -884,7 +883,7 @@ class ExponentialReconnectionPolicyTest(unittest.TestCase): self.assertRaises(ValueError, ExponentialReconnectionPolicy, -1, 0) self.assertRaises(ValueError, ExponentialReconnectionPolicy, 0, -1) self.assertRaises(ValueError, ExponentialReconnectionPolicy, 9000, 1) - self.assertRaises(ValueError, ExponentialReconnectionPolicy, 1, 2,-1) + self.assertRaises(ValueError, ExponentialReconnectionPolicy, 1, 2, -1) def test_schedule_no_max(self): base_delay = 2.0 @@ -1235,8 +1234,7 @@ class WhiteListRoundRobinPolicyTest(unittest.TestCase): class AddressTranslatorTest(unittest.TestCase): def test_identity_translator(self): - it = IdentityTranslator() - addr = '127.0.0.1' + IdentityTranslator() @patch('socket.getfqdn', return_value='localhost') def test_ec2_multi_region_translator(self, *_):