2424from cassandra .concurrent import execute_concurrent_with_args
2525from cassandra .cqlengine import models
2626
27+ from tests .integration .cqlengine import setup_connection
2728from tests .integration .cqlengine .base import BaseCassEngTestCase
2829from tests .integration .cqlengine .query .test_queryset import BaseQuerySetUsage
2930
@@ -128,7 +129,7 @@ def setUpClass(cls):
128129
129130 from tests .integration .cqlengine .query .test_queryset import TestModel
130131
131- ks ,tn = TestModel .column_family_name ().split ('.' )
132+ ks , tn = TestModel .column_family_name ().split ('.' )
132133 cls .keyspace = NamedKeyspace (ks )
133134 cls .table = cls .keyspace .table (tn )
134135
@@ -149,8 +150,8 @@ def test_query_expression_count(self):
149150 def test_iteration (self ):
150151 """ Tests that iterating over a query set pulls back all of the expected results """
151152 q = self .table .objects (test_id = 0 )
152- #tuple of expected attempt_id, expected_result values
153- compare_set = set ([(0 ,5 ), (1 ,10 ), (2 ,15 ), (3 ,20 )])
153+ # tuple of expected attempt_id, expected_result values
154+ compare_set = set ([(0 , 5 ), (1 , 10 ), (2 , 15 ), (3 , 20 )])
154155 for t in q :
155156 val = t .attempt_id , t .expected_result
156157 assert val in compare_set
@@ -160,8 +161,8 @@ def test_iteration(self):
160161 # test with regular filtering
161162 q = self .table .objects (attempt_id = 3 ).allow_filtering ()
162163 assert len (q ) == 3
163- #tuple of expected test_id, expected_result values
164- compare_set = set ([(0 ,20 ), (1 ,20 ), (2 ,75 )])
164+ # tuple of expected test_id, expected_result values
165+ compare_set = set ([(0 , 20 ), (1 , 20 ), (2 , 75 )])
165166 for t in q :
166167 val = t .test_id , t .expected_result
167168 assert val in compare_set
@@ -171,8 +172,8 @@ def test_iteration(self):
171172 # test with query method
172173 q = self .table .objects (self .table .column ('attempt_id' ) == 3 ).allow_filtering ()
173174 assert len (q ) == 3
174- #tuple of expected test_id, expected_result values
175- compare_set = set ([(0 ,20 ), (1 ,20 ), (2 ,75 )])
175+ # tuple of expected test_id, expected_result values
176+ compare_set = set ([(0 , 20 ), (1 , 20 ), (2 , 75 )])
176177 for t in q :
177178 val = t .test_id , t .expected_result
178179 assert val in compare_set
@@ -183,16 +184,16 @@ def test_multiple_iterations_work_properly(self):
183184 """ Tests that iterating over a query set more than once works """
184185 # test with both the filtering method and the query method
185186 for q in (self .table .objects (test_id = 0 ), self .table .objects (self .table .column ('test_id' ) == 0 )):
186- #tuple of expected attempt_id, expected_result values
187- compare_set = set ([(0 ,5 ), (1 ,10 ), (2 ,15 ), (3 ,20 )])
187+ # tuple of expected attempt_id, expected_result values
188+ compare_set = set ([(0 , 5 ), (1 , 10 ), (2 , 15 ), (3 , 20 )])
188189 for t in q :
189190 val = t .attempt_id , t .expected_result
190191 assert val in compare_set
191192 compare_set .remove (val )
192193 assert len (compare_set ) == 0
193194
194- #try it again
195- compare_set = set ([(0 ,5 ), (1 ,10 ), (2 ,15 ), (3 ,20 )])
195+ # try it again
196+ compare_set = set ([(0 , 5 ), (1 , 10 ), (2 , 15 ), (3 , 20 )])
196197 for t in q :
197198 val = t .attempt_id , t .expected_result
198199 assert val in compare_set
@@ -205,7 +206,7 @@ def test_multiple_iterators_are_isolated(self):
205206 """
206207 for q in (self .table .objects (test_id = 0 ), self .table .objects (self .table .column ('test_id' ) == 0 )):
207208 q = q .order_by ('attempt_id' )
208- expected_order = [0 ,1 , 2 , 3 ]
209+ expected_order = [0 , 1 , 2 , 3 ]
209210 iter1 = iter (q )
210211 iter2 = iter (q )
211212 for attempt_id in expected_order :
@@ -280,6 +281,7 @@ def setUp(self):
280281
281282 def tearDown (self ):
282283 models .DEFAULT_KEYSPACE = self .default_keyspace
284+ setup_connection (models .DEFAULT_KEYSPACE )
283285
284286 def test_named_table_with_mv (self ):
285287 """
0 commit comments