@@ -67,7 +67,8 @@ def test_ctor_w_bqstorage_client(self):
6767mock_client = self ._mock_client ()
6868mock_bqstorage_client = self ._mock_bqstorage_client ()
6969connection = self ._make_one (
70- client = mock_client ,bqstorage_client = mock_bqstorage_client ,
70+ client = mock_client ,
71+ bqstorage_client = mock_bqstorage_client ,
7172 )
7273self .assertIsInstance (connection ,Connection )
7374self .assertIs (connection ._client ,mock_client )
@@ -109,7 +110,8 @@ def test_connect_w_both_clients(self):
109110mock_client = self ._mock_client ()
110111mock_bqstorage_client = self ._mock_bqstorage_client ()
111112connection = connect (
112- client = mock_client ,bqstorage_client = mock_bqstorage_client ,
113+ client = mock_client ,
114+ bqstorage_client = mock_bqstorage_client ,
113115 )
114116self .assertIsInstance (connection ,Connection )
115117self .assertIs (connection ._client ,mock_client )
@@ -140,7 +142,9 @@ def test_close_closes_all_created_bigquery_clients(self):
140142return_value = client ,
141143 )
142144bqstorage_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 ,
144148 )
145149
146150with client_patcher ,bqstorage_client_patcher :
@@ -156,7 +160,7 @@ def test_close_closes_all_created_bigquery_clients(self):
156160 )
157161def test_close_does_not_close_bigquery_clients_passed_to_it (self ):
158162client = self ._mock_client ()
159- bqstorage_client = self ._mock_bqstorage_client ()
163+ bqstorage_client = sesf ._mock_bqstorage_client ()
160164connection = self ._make_one (client = client ,bqstorage_client = bqstorage_client )
161165
162166connection .close ()
@@ -176,6 +180,19 @@ def test_close_closes_all_created_cursors(self):
176180self .assertTrue (cursor_1 ._closed )
177181self .assertTrue (cursor_2 ._closed )
178182
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+
179196def test_does_not_keep_cursor_instances_alive (self ):
180197from google .cloud .bigquery .dbapi import Cursor
181198