@@ -41,12 +41,8 @@ def test_load_dialect_impl_mysql(pickle_type):
4141
4242 impl = pickle_type .load_dialect_impl (mock_dialect )
4343
44- # Verify type_descriptor was called once
45- assert mock_dialect .type_descriptor .call_count == 1
46- # Verify it was called with mysql.LONGBLOB type
47- call_args = mock_dialect .type_descriptor .call_args [0 ][0 ]
48- assert call_args .__name__ == "LONGBLOB"
49- assert call_args == mysql .LONGBLOB
44+ # Verify type_descriptor was called once with mysql.LONGBLOB
45+ mock_dialect .type_descriptor .assert_called_once_with (mysql .LONGBLOB )
5046 # Verify the return value is what we expect
5147 assert impl == mock_longblob_type
5248
@@ -73,24 +69,17 @@ def test_load_dialect_impl_default(pickle_type):
7369 assert impl == pickle_type .impl
7470
7571
76- def test_process_bind_param_mysql (pickle_type ):
77- """Test that MySQL dialect pickles the value."""
72+ @pytest .mark .parametrize (
73+ "dialect_name" ,
74+ [
75+ pytest .param ("mysql" , id = "mysql" ),
76+ pytest .param ("spanner+spanner" , id = "spanner" ),
77+ ],
78+ )
79+ def test_process_bind_param_pickle_dialects (pickle_type , dialect_name ):
80+ """Test that MySQL and Spanner dialects pickle the value."""
7881 mock_dialect = mock .Mock ()
79- mock_dialect .name = "mysql"
80-
81- test_data = {"key" : "value" , "nested" : [1 , 2 , 3 ]}
82- result = pickle_type .process_bind_param (test_data , mock_dialect )
83-
84- # Should be pickled bytes
85- assert isinstance (result , bytes )
86- # Should be able to unpickle back to original
87- assert pickle .loads (result ) == test_data
88-
89-
90- def test_process_bind_param_spanner (pickle_type ):
91- """Test that Spanner dialect pickles the value."""
92- mock_dialect = mock .Mock ()
93- mock_dialect .name = "spanner+spanner"
82+ mock_dialect .name = dialect_name
9483
9584 test_data = {"key" : "value" , "nested" : [1 , 2 , 3 ]}
9685 result = pickle_type .process_bind_param (test_data , mock_dialect )
@@ -122,24 +111,17 @@ def test_process_bind_param_none(pickle_type):
122111 assert result is None
123112
124113
125- def test_process_result_value_mysql (pickle_type ):
126- """Test that MySQL dialect unpickles the value."""
127- mock_dialect = mock .Mock ()
128- mock_dialect .name = "mysql"
129-
130- test_data = {"key" : "value" , "nested" : [1 , 2 , 3 ]}
131- pickled_data = pickle .dumps (test_data )
132-
133- result = pickle_type .process_result_value (pickled_data , mock_dialect )
134-
135- # Should be unpickled back to original
136- assert result == test_data
137-
138-
139- def test_process_result_value_spanner (pickle_type ):
140- """Test that Spanner dialect unpickles the value."""
114+ @pytest .mark .parametrize (
115+ "dialect_name" ,
116+ [
117+ pytest .param ("mysql" , id = "mysql" ),
118+ pytest .param ("spanner+spanner" , id = "spanner" ),
119+ ],
120+ )
121+ def test_process_result_value_pickle_dialects (pickle_type , dialect_name ):
122+ """Test that MySQL and Spanner dialects unpickle the value."""
141123 mock_dialect = mock .Mock ()
142- mock_dialect .name = "spanner+spanner"
124+ mock_dialect .name = dialect_name
143125
144126 test_data = {"key" : "value" , "nested" : [1 , 2 , 3 ]}
145127 pickled_data = pickle .dumps (test_data )
@@ -171,31 +153,17 @@ def test_process_result_value_none(pickle_type):
171153 assert result is None
172154
173155
174- def test_roundtrip_mysql (pickle_type ):
175- """Test full roundtrip for MySQL: bind -> result."""
156+ @pytest .mark .parametrize (
157+ "dialect_name" ,
158+ [
159+ pytest .param ("mysql" , id = "mysql" ),
160+ pytest .param ("spanner+spanner" , id = "spanner" ),
161+ ],
162+ )
163+ def test_roundtrip_pickle_dialects (pickle_type , dialect_name ):
164+ """Test full roundtrip for MySQL and Spanner: bind -> result."""
176165 mock_dialect = mock .Mock ()
177- mock_dialect .name = "mysql"
178-
179- original_data = {
180- "string" : "test" ,
181- "number" : 42 ,
182- "list" : [1 , 2 , 3 ],
183- "nested" : {"a" : 1 , "b" : 2 },
184- }
185-
186- # Simulate bind (Python -> DB)
187- bound_value = pickle_type .process_bind_param (original_data , mock_dialect )
188- assert isinstance (bound_value , bytes )
189-
190- # Simulate result (DB -> Python)
191- result_value = pickle_type .process_result_value (bound_value , mock_dialect )
192- assert result_value == original_data
193-
194-
195- def test_roundtrip_spanner (pickle_type ):
196- """Test full roundtrip for Spanner: bind -> result."""
197- mock_dialect = mock .Mock ()
198- mock_dialect .name = "spanner+spanner"
166+ mock_dialect .name = dialect_name
199167
200168 original_data = {
201169 "string" : "test" ,
0 commit comments