Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 38b23da

Browse files
Lorak-mmkdkropachev
authored andcommitted
assert_quiescent_pool_state: Use plain asserts
1 parent 07f01bb commit 38b23da

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

‎tests/integration/simulacron/test_connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_callbacks_and_pool_when_oto(self):
185185
with pytest.raises(OperationTimedOut):
186186
future.result()
187187

188-
assert_quiescent_pool_state(self, cluster)
188+
assert_quiescent_pool_state(cluster)
189189

190190
time.sleep(server_delay + 1)
191191
# PYTHON-630 -- only the errback should be called
@@ -358,11 +358,11 @@ def test_retry_after_defunct(self):
358358

359359
# Might take some time to close the previous connections and reconnect
360360
time.sleep(10)
361-
assert_quiescent_pool_state(self, cluster)
361+
assert_quiescent_pool_state(cluster)
362362
clear_queries()
363363

364364
time.sleep(10)
365-
assert_quiescent_pool_state(self, cluster)
365+
assert_quiescent_pool_state(cluster)
366366

367367
def test_idle_connection_is_not_closed(self):
368368
"""
@@ -425,7 +425,7 @@ def test_host_is_not_set_to_down_after_query_oto(self):
425425
assert isinstance(f._final_exception, OperationTimedOut)
426426

427427
assert listener.hosts_marked_down == []
428-
assert_quiescent_pool_state(self, cluster)
428+
assert_quiescent_pool_state(cluster)
429429

430430
def test_can_shutdown_connection_subclass(self):
431431
start_and_prime_singledc()

‎tests/integration/standard/test_authentication.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_auth_connect(self):
107107
session = cluster.connect(wait_for_all_pools=True)
108108
try:
109109
assert session.execute("SELECT release_version FROM system.local WHERE key='local'")
110-
assert_quiescent_pool_state(self, cluster, wait=1)
110+
assert_quiescent_pool_state(cluster, wait=1)
111111
for pool in session.get_pools():
112112
connection, _ = pool.borrow_connection(timeout=0)
113113
assert connection.authenticator.server_authenticator_class == 'org.apache.cassandra.auth.PasswordAuthenticator'
@@ -116,15 +116,15 @@ def test_auth_connect(self):
116116
cluster.shutdown()
117117
finally:
118118
root_session.execute('DROP USER %s', user)
119-
assert_quiescent_pool_state(self, root_session.cluster, wait=1)
119+
assert_quiescent_pool_state(root_session.cluster, wait=1)
120120
root_session.cluster.shutdown()
121121

122122
def test_connect_wrong_pwd(self):
123123
cluster = self.cluster_as('cassandra', 'wrong_pass')
124124
try:
125125
with pytest.raises(NoHostAvailable, match='.*AuthenticationFailed.'):
126126
cluster.connect()
127-
assert_quiescent_pool_state(self, cluster)
127+
assert_quiescent_pool_state(cluster)
128128
finally:
129129
cluster.shutdown()
130130

@@ -133,7 +133,7 @@ def test_connect_wrong_username(self):
133133
try:
134134
with pytest.raises(NoHostAvailable, match='.*AuthenticationFailed.*'):
135135
cluster.connect()
136-
assert_quiescent_pool_state(self, cluster)
136+
assert_quiescent_pool_state(cluster)
137137
finally:
138138
cluster.shutdown()
139139

@@ -142,7 +142,7 @@ def test_connect_empty_pwd(self):
142142
try:
143143
with pytest.raises(NoHostAvailable, match='.*AuthenticationFailed.*'):
144144
cluster.connect()
145-
assert_quiescent_pool_state(self, cluster)
145+
assert_quiescent_pool_state(cluster)
146146
finally:
147147
cluster.shutdown()
148148

@@ -151,7 +151,7 @@ def test_connect_no_auth_provider(self):
151151
try:
152152
with pytest.raises(NoHostAvailable, match='.*AuthenticationFailed.*'):
153153
cluster.connect()
154-
assert_quiescent_pool_state(self, cluster)
154+
assert_quiescent_pool_state(cluster)
155155
finally:
156156
cluster.shutdown()
157157

‎tests/integration/standard/test_cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def test_idle_heartbeat(self):
781781

782782
cluster._idle_heartbeat.stop()
783783
cluster._idle_heartbeat.join()
784-
assert_quiescent_pool_state(self, cluster)
784+
assert_quiescent_pool_state(cluster)
785785

786786
cluster.shutdown()
787787

@@ -829,7 +829,7 @@ def test_pool_management(self):
829829
cluster.refresh_schema_metadata()
830830
cluster.refresh_schema_metadata(max_schema_agreement_wait=0)
831831

832-
assert_quiescent_pool_state(self, cluster)
832+
assert_quiescent_pool_state(cluster)
833833

834834
cluster.shutdown()
835835

‎tests/integration/util.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
import time
1919

2020

21-
def assert_quiescent_pool_state(test_case, cluster, wait=None):
21+
def assert_quiescent_pool_state(cluster, wait=None):
2222
"""
2323
Checking the quiescent pool state checks that none of the requests ids have
2424
been lost. However, the callback corresponding to a request_id is called
2525
before the request_id is returned back to the pool, therefore
2626
2727
session.execute("SELECT * from system.local")
28-
assert_quiescent_pool_state(self, session.cluster)
28+
assert_quiescent_pool_state(session.cluster)
2929
3030
(with no wait) might fail because when execute comes back the request_id
3131
hasn't yet been returned to the pool, therefore the wait.
@@ -35,23 +35,23 @@ def assert_quiescent_pool_state(test_case, cluster, wait=None):
3535

3636
for session in cluster.sessions:
3737
pool_states = session.get_pool_state().values()
38-
test_case.assertTrue(pool_states)
38+
assertpool_states
3939

4040
for state in pool_states:
41-
test_case.assertFalse(state['shutdown'])
42-
test_case.assertGreater(state['open_count'], 0)
41+
assertnotstate['shutdown']
42+
assertstate['open_count']>0
4343
no_in_flight = all((i == 0 for i in state['in_flights']))
4444
orphans_and_inflights = zip(state['orphan_requests'],state['in_flights'])
4545
all_orphaned = all((len(orphans) == inflight for (orphans,inflight) in orphans_and_inflights))
46-
test_case.assertTrue(no_in_flight or all_orphaned)
46+
assertno_in_flight or all_orphaned
4747

4848
for holder in cluster.get_connection_holders():
4949
for connection in holder.get_connections():
5050
# all ids are unique
5151
req_ids = connection.request_ids
5252
orphan_ids = connection.orphaned_request_ids
53-
test_case.assertEqual(len(req_ids), len(set(req_ids)))
54-
test_case.assertEqual(connection.highest_request_id, len(req_ids) + len(orphan_ids) - 1)
55-
test_case.assertEqual(connection.highest_request_id, max(chain(req_ids, orphan_ids)))
53+
assertlen(req_ids)==len(set(req_ids))
54+
assertconnection.highest_request_id==len(req_ids) + len(orphan_ids) - 1
55+
assertconnection.highest_request_id==max(chain(req_ids, orphan_ids))
5656
if PROTOCOL_VERSION < 3:
57-
test_case.assertEqual(connection.highest_request_id, connection.max_request_id)
57+
assertconnection.highest_request_id==connection.max_request_id

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /