Skip to content

Commit 662e12f

Browse files
beltranmambocab
authored andcommitted
Use _global_loop in tests
1 parent 97cbab0 commit 662e12f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests/unit/io/test_libevreactor.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class LibevConnectionTest(ReactorTestMixin, unittest.TestCase):
3535

3636
connection_class = LibevConnection
3737
socket_attr_name = '_socket'
38-
loop_attr_name = '_libevloop'
3938
null_handle_function_args = None, 0
4039

4140
def setUp(self):
@@ -62,7 +61,7 @@ def test_watchers_are_finished(self):
6261
Test for asserting that watchers are closed in LibevConnection
6362
6463
This test simulates a process termination without calling cluster.shutdown(), which would trigger
65-
LibevConnection._libevloop._cleanup. It will check the watchers have been closed
64+
_global_loop._cleanup. It will check the watchers have been closed
6665
Finally it will restore the LibevConnection reactor so it doesn't affect
6766
the rest of the tests
6867
@@ -72,24 +71,25 @@ def test_watchers_are_finished(self):
7271
7372
@test_category connection
7473
"""
75-
with patch.object(LibevConnection._libevloop, "_thread"),\
76-
patch.object(LibevConnection._libevloop, "notify"):
74+
from cassandra.io.libevreactor import _global_loop
75+
with patch.object(_global_loop, "_thread"),\
76+
patch.object(_global_loop, "notify"):
7777

7878
self.make_connection()
7979

8080
# We have to make a copy because the connections shouldn't
8181
# be alive when we verify them
82-
live_connections = set(LibevConnection._libevloop._live_conns)
82+
live_connections = set(_global_loop._live_conns)
8383

8484
# This simulates the process ending without cluster.shutdown()
8585
# being called, then with atexit _cleanup for libevreactor would
8686
# be called
87-
libev__cleanup(weakref.ref(LibevConnection._libevloop))
87+
libev__cleanup(_global_loop)
8888
for conn in live_connections:
8989
self.assertTrue(conn._write_watcher.stop.mock_calls)
9090
self.assertTrue(conn._read_watcher.stop.mock_calls)
9191

92-
LibevConnection._libevloop._shutdown = False
92+
_global_loop._shutdown = False
9393

9494

9595
class LibevTimerPatcher(unittest.TestCase):
@@ -125,7 +125,8 @@ def create_timer(self):
125125

126126
@property
127127
def _timers(self):
128-
return self.connection._libevloop._timers
128+
from cassandra.io.libevreactor import _global_loop
129+
return _global_loop._timers
129130

130131
def make_connection(self):
131132
c = LibevConnection('1.2.3.4', cql_version='3.0.1')

0 commit comments

Comments
 (0)