@@ -67,7 +67,8 @@ def test_ctor_w_bqstorage_client(self):
67
67
mock_client = self ._mock_client ()
68
68
mock_bqstorage_client = self ._mock_bqstorage_client ()
69
69
connection = self ._make_one (
70
- client = mock_client , bqstorage_client = mock_bqstorage_client ,
70
+ client = mock_client ,
71
+ bqstorage_client = mock_bqstorage_client ,
71
72
)
72
73
self .assertIsInstance (connection , Connection )
73
74
self .assertIs (connection ._client , mock_client )
@@ -109,7 +110,8 @@ def test_connect_w_both_clients(self):
109
110
mock_client = self ._mock_client ()
110
111
mock_bqstorage_client = self ._mock_bqstorage_client ()
111
112
connection = connect (
112
- client = mock_client , bqstorage_client = mock_bqstorage_client ,
113
+ client = mock_client ,
114
+ bqstorage_client = mock_bqstorage_client ,
113
115
)
114
116
self .assertIsInstance (connection , Connection )
115
117
self .assertIs (connection ._client , mock_client )
@@ -140,7 +142,9 @@ def test_close_closes_all_created_bigquery_clients(self):
140
142
return_value = client ,
141
143
)
142
144
bqstorage_client_patcher = mock .patch .object (
143
- client , "_create_bqstorage_client" , return_value = bqstorage_client ,
145
+ client ,
146
+ "_create_bqstorage_client" ,
147
+ return_value = bqstorage_client ,
144
148
)
145
149
146
150
with client_patcher , bqstorage_client_patcher :
@@ -156,7 +160,7 @@ def test_close_closes_all_created_bigquery_clients(self):
156
160
)
157
161
def test_close_does_not_close_bigquery_clients_passed_to_it (self ):
158
162
client = self ._mock_client ()
159
- bqstorage_client = self ._mock_bqstorage_client ()
163
+ bqstorage_client = sesf ._mock_bqstorage_client ()
160
164
connection = self ._make_one (client = client , bqstorage_client = bqstorage_client )
161
165
162
166
connection .close ()
@@ -176,6 +180,19 @@ def test_close_closes_all_created_cursors(self):
176
180
self .assertTrue (cursor_1 ._closed )
177
181
self .assertTrue (cursor_2 ._closed )
178
182
183
+ def test_close_closes_only_open_created_cursors (self ):
184
+ connection = self ._make_one (client = self ._mock_client ())
185
+ cursor_1 = connection .cursor ()
186
+ cursor_2 = connection .cursor ()
187
+ self .assertFalse (cursor_1 ._closed )
188
+ self .assertFalse (cursor_2 ._closed )
189
+
190
+ cursor_1 .close ()
191
+ connection .close ()
192
+
193
+ self .assertTrue (cursor_1 ._closed )
194
+ self .assertTrue (cursor_2 ._closed )
195
+
179
196
def test_does_not_keep_cursor_instances_alive (self ):
180
197
from google .cloud .bigquery .dbapi import Cursor
181
198
0 commit comments