@@ -20,6 +20,7 @@ class TestTimestampWithNanoseconds(unittest.TestCase):
2020
2121 def _get_target_class (self ):
2222 from google .cloud .spanner ._helpers import TimestampWithNanoseconds
23+
2324 return TimestampWithNanoseconds
2425
2526 def _make_one (self , * args , ** kw ):
@@ -82,6 +83,7 @@ def test_from_rfc3339_w_invalid(self):
8283
8384 def test_from_rfc3339_wo_fraction (self ):
8485 from google .cloud ._helpers import UTC
86+
8587 klass = self ._get_target_class ()
8688 STAMP = '2016-12-20T21:13:47Z'
8789 expected = self ._make_one (2016 , 12 , 20 , 21 , 13 , 47 , tzinfo = UTC )
@@ -90,6 +92,7 @@ def test_from_rfc3339_wo_fraction(self):
9092
9193 def test_from_rfc3339_w_partial_precision (self ):
9294 from google .cloud ._helpers import UTC
95+
9396 klass = self ._get_target_class ()
9497 STAMP = '2016-12-20T21:13:47.1Z'
9598 expected = self ._make_one (2016 , 12 , 20 , 21 , 13 , 47 ,
@@ -99,6 +102,7 @@ def test_from_rfc3339_w_partial_precision(self):
99102
100103 def test_from_rfc3339_w_full_precision (self ):
101104 from google .cloud ._helpers import UTC
105+
102106 klass = self ._get_target_class ()
103107 STAMP = '2016-12-20T21:13:47.123456789Z'
104108 expected = self ._make_one (2016 , 12 , 20 , 21 , 13 , 47 ,
@@ -111,6 +115,7 @@ class Test_make_value_pb(unittest.TestCase):
111115
112116 def _callFUT (self , * args , ** kw ):
113117 from google .cloud .spanner ._helpers import _make_value_pb
118+
114119 return _make_value_pb (* args , ** kw )
115120
116121 def test_w_None (self ):
@@ -119,6 +124,7 @@ def test_w_None(self):
119124
120125 def test_w_bytes (self ):
121126 from google .protobuf .struct_pb2 import Value
127+
122128 BYTES = b'BYTES'
123129 expected = Value (string_value = BYTES )
124130 value_pb = self ._callFUT (BYTES )
@@ -132,6 +138,7 @@ def test_w_invalid_bytes(self):
132138
133139 def test_w_explicit_unicode (self ):
134140 from google .protobuf .struct_pb2 import Value
141+
135142 TEXT = u'TEXT'
136143 value_pb = self ._callFUT (TEXT )
137144 self .assertIsInstance (value_pb , Value )
@@ -140,6 +147,7 @@ def test_w_explicit_unicode(self):
140147 def test_w_list (self ):
141148 from google .protobuf .struct_pb2 import Value
142149 from google .protobuf .struct_pb2 import ListValue
150+
143151 value_pb = self ._callFUT ([u'a' , u'b' , u'c' ])
144152 self .assertIsInstance (value_pb , Value )
145153 self .assertIsInstance (value_pb .list_value , ListValue )
@@ -149,45 +157,52 @@ def test_w_list(self):
149157
150158 def test_w_bool (self ):
151159 from google .protobuf .struct_pb2 import Value
160+
152161 value_pb = self ._callFUT (True )
153162 self .assertIsInstance (value_pb , Value )
154163 self .assertEqual (value_pb .bool_value , True )
155164
156165 def test_w_int (self ):
157166 import six
158167 from google .protobuf .struct_pb2 import Value
168+
159169 for int_type in six .integer_types : # include 'long' on Python 2
160170 value_pb = self ._callFUT (int_type (42 ))
161171 self .assertIsInstance (value_pb , Value )
162172 self .assertEqual (value_pb .string_value , '42' )
163173
164174 def test_w_float (self ):
165175 from google .protobuf .struct_pb2 import Value
176+
166177 value_pb = self ._callFUT (3.14159 )
167178 self .assertIsInstance (value_pb , Value )
168179 self .assertEqual (value_pb .number_value , 3.14159 )
169180
170181 def test_w_float_nan (self ):
171182 from google .protobuf .struct_pb2 import Value
183+
172184 value_pb = self ._callFUT (float ('nan' ))
173185 self .assertIsInstance (value_pb , Value )
174186 self .assertEqual (value_pb .string_value , 'NaN' )
175187
176188 def test_w_float_neg_inf (self ):
177189 from google .protobuf .struct_pb2 import Value
190+
178191 value_pb = self ._callFUT (float ('-inf' ))
179192 self .assertIsInstance (value_pb , Value )
180193 self .assertEqual (value_pb .string_value , '-inf' )
181194
182195 def test_w_float_pos_inf (self ):
183196 from google .protobuf .struct_pb2 import Value
197+
184198 value_pb = self ._callFUT (float ('inf' ))
185199 self .assertIsInstance (value_pb , Value )
186200 self .assertEqual (value_pb .string_value , 'inf' )
187201
188202 def test_w_date (self ):
189203 import datetime
190204 from google .protobuf .struct_pb2 import Value
205+
191206 today = datetime .date .today ()
192207 value_pb = self ._callFUT (today )
193208 self .assertIsInstance (value_pb , Value )
@@ -197,6 +212,7 @@ def test_w_timestamp_w_nanos(self):
197212 from google .protobuf .struct_pb2 import Value
198213 from google .cloud ._helpers import UTC
199214 from google .cloud .spanner ._helpers import TimestampWithNanoseconds
215+
200216 when = TimestampWithNanoseconds (
201217 2016 , 12 , 20 , 21 , 13 , 47 , nanosecond = 123456789 , tzinfo = UTC )
202218 value_pb = self ._callFUT (when )
@@ -207,6 +223,7 @@ def test_w_datetime(self):
207223 import datetime
208224 from google .protobuf .struct_pb2 import Value
209225 from google .cloud ._helpers import UTC , _datetime_to_rfc3339
226+
210227 now = datetime .datetime .utcnow ().replace (tzinfo = UTC )
211228 value_pb = self ._callFUT (now )
212229 self .assertIsInstance (value_pb , Value )
@@ -221,16 +238,19 @@ class Test_make_list_value_pb(unittest.TestCase):
221238
222239 def _callFUT (self , * args , ** kw ):
223240 from google .cloud .spanner ._helpers import _make_list_value_pb
241+
224242 return _make_list_value_pb (* args , ** kw )
225243
226244 def test_empty (self ):
227245 from google .protobuf .struct_pb2 import ListValue
246+
228247 result = self ._callFUT (values = [])
229248 self .assertIsInstance (result , ListValue )
230249 self .assertEqual (len (result .values ), 0 )
231250
232251 def test_w_single_value (self ):
233252 from google .protobuf .struct_pb2 import ListValue
253+
234254 VALUE = u'value'
235255 result = self ._callFUT (values = [VALUE ])
236256 self .assertIsInstance (result , ListValue )
@@ -239,6 +259,7 @@ def test_w_single_value(self):
239259
240260 def test_w_multiple_values (self ):
241261 from google .protobuf .struct_pb2 import ListValue
262+
242263 VALUE_1 = u'value'
243264 VALUE_2 = 42
244265 result = self ._callFUT (values = [VALUE_1 , VALUE_2 ])
@@ -252,6 +273,7 @@ class Test_make_list_value_pbs(unittest.TestCase):
252273
253274 def _callFUT (self , * args , ** kw ):
254275 from google .cloud .spanner ._helpers import _make_list_value_pbs
276+
255277 return _make_list_value_pbs (* args , ** kw )
256278
257279 def test_empty (self ):
@@ -260,6 +282,7 @@ def test_empty(self):
260282
261283 def test_w_single_values (self ):
262284 from google .protobuf .struct_pb2 import ListValue
285+
263286 values = [[0 ], [1 ]]
264287 result = self ._callFUT (values = values )
265288 self .assertEqual (len (result ), len (values ))
@@ -270,6 +293,7 @@ def test_w_single_values(self):
270293
271294 def test_w_multiple_values (self ):
272295 from google .protobuf .struct_pb2 import ListValue
296+
273297 values = [[0 , u'A' ], [1 , u'B' ]]
274298 result = self ._callFUT (values = values )
275299 self .assertEqual (len (result ), len (values ))
@@ -284,11 +308,13 @@ class Test_parse_value_pb(unittest.TestCase):
284308
285309 def _callFUT (self , * args , ** kw ):
286310 from google .cloud .spanner ._helpers import _parse_value_pb
311+
287312 return _parse_value_pb (* args , ** kw )
288313
289314 def test_w_null (self ):
290315 from google .protobuf .struct_pb2 import Value , NULL_VALUE
291316 from google .cloud .proto .spanner .v1 .type_pb2 import Type , STRING
317+
292318 field_type = Type (code = STRING )
293319 value_pb = Value (null_value = NULL_VALUE )
294320
@@ -297,6 +323,7 @@ def test_w_null(self):
297323 def test_w_string (self ):
298324 from google .protobuf .struct_pb2 import Value
299325 from google .cloud .proto .spanner .v1 .type_pb2 import Type , STRING
326+
300327 VALUE = u'Value'
301328 field_type = Type (code = STRING )
302329 value_pb = Value (string_value = VALUE )
@@ -306,6 +333,7 @@ def test_w_string(self):
306333 def test_w_bytes (self ):
307334 from google .protobuf .struct_pb2 import Value
308335 from google .cloud .proto .spanner .v1 .type_pb2 import Type , BYTES
336+
309337 VALUE = b'Value'
310338 field_type = Type (code = BYTES )
311339 value_pb = Value (string_value = VALUE )
@@ -315,6 +343,7 @@ def test_w_bytes(self):
315343 def test_w_bool (self ):
316344 from google .protobuf .struct_pb2 import Value
317345 from google .cloud .proto .spanner .v1 .type_pb2 import Type , BOOL
346+
318347 VALUE = True
319348 field_type = Type (code = BOOL )
320349 value_pb = Value (bool_value = VALUE )
@@ -324,6 +353,7 @@ def test_w_bool(self):
324353 def test_w_int (self ):
325354 from google .protobuf .struct_pb2 import Value
326355 from google .cloud .proto .spanner .v1 .type_pb2 import Type , INT64
356+
327357 VALUE = 12345
328358 field_type = Type (code = INT64 )
329359 value_pb = Value (string_value = str (VALUE ))
@@ -333,6 +363,7 @@ def test_w_int(self):
333363 def test_w_float (self ):
334364 from google .protobuf .struct_pb2 import Value
335365 from google .cloud .proto .spanner .v1 .type_pb2 import Type , FLOAT64
366+
336367 VALUE = 3.14159
337368 field_type = Type (code = FLOAT64 )
338369 value_pb = Value (number_value = VALUE )
@@ -343,6 +374,7 @@ def test_w_date(self):
343374 import datetime
344375 from google .protobuf .struct_pb2 import Value
345376 from google .cloud .proto .spanner .v1 .type_pb2 import Type , DATE
377+
346378 VALUE = datetime .date .today ()
347379 field_type = Type (code = DATE )
348380 value_pb = Value (string_value = VALUE .isoformat ())
@@ -354,6 +386,7 @@ def test_w_timestamp_wo_nanos(self):
354386 from google .cloud .proto .spanner .v1 .type_pb2 import Type , TIMESTAMP
355387 from google .cloud ._helpers import UTC , _datetime_to_rfc3339
356388 from google .cloud .spanner ._helpers import TimestampWithNanoseconds
389+
357390 VALUE = TimestampWithNanoseconds (
358391 2016 , 12 , 20 , 21 , 13 , 47 , microsecond = 123456 , tzinfo = UTC )
359392 field_type = Type (code = TIMESTAMP )
@@ -368,6 +401,7 @@ def test_w_timestamp_w_nanos(self):
368401 from google .cloud .proto .spanner .v1 .type_pb2 import Type , TIMESTAMP
369402 from google .cloud ._helpers import UTC , _datetime_to_rfc3339
370403 from google .cloud .spanner ._helpers import TimestampWithNanoseconds
404+
371405 VALUE = TimestampWithNanoseconds (
372406 2016 , 12 , 20 , 21 , 13 , 47 , nanosecond = 123456789 , tzinfo = UTC )
373407 field_type = Type (code = TIMESTAMP )
@@ -380,6 +414,7 @@ def test_w_timestamp_w_nanos(self):
380414 def test_w_array_empty (self ):
381415 from google .protobuf .struct_pb2 import Value
382416 from google .cloud .proto .spanner .v1 .type_pb2 import Type , ARRAY , INT64
417+
383418 field_type = Type (code = ARRAY , array_element_type = Type (code = INT64 ))
384419 value_pb = Value ()
385420
@@ -388,6 +423,7 @@ def test_w_array_empty(self):
388423 def test_w_array_non_empty (self ):
389424 from google .protobuf .struct_pb2 import Value , ListValue
390425 from google .cloud .proto .spanner .v1 .type_pb2 import Type , ARRAY , INT64
426+
391427 field_type = Type (code = ARRAY , array_element_type = Type (code = INT64 ))
392428 VALUES = [32 , 19 , 5 ]
393429 values_pb = ListValue (
@@ -402,6 +438,7 @@ def test_w_struct(self):
402438 from google .cloud .proto .spanner .v1 .type_pb2 import (
403439 STRUCT , STRING , INT64 )
404440 from google .cloud .spanner ._helpers import _make_list_value_pb
441+
405442 VALUES = [u'phred' , 32 ]
406443 struct_type_pb = StructType (fields = [
407444 StructType .Field (name = 'name' , type = Type (code = STRING )),
@@ -417,6 +454,7 @@ def test_w_unknown_type(self):
417454 from google .cloud .proto .spanner .v1 .type_pb2 import Type
418455 from google .cloud .proto .spanner .v1 .type_pb2 import (
419456 TYPE_CODE_UNSPECIFIED )
457+
420458 field_type = Type (code = TYPE_CODE_UNSPECIFIED )
421459 value_pb = Value (string_value = 'Borked' )
422460
@@ -428,11 +466,13 @@ class Test_parse_list_value_pbs(unittest.TestCase):
428466
429467 def _callFUT (self , * args , ** kw ):
430468 from google .cloud .spanner ._helpers import _parse_list_value_pbs
469+
431470 return _parse_list_value_pbs (* args , ** kw )
432471
433472 def test_empty (self ):
434473 from google .cloud .proto .spanner .v1 .type_pb2 import Type , StructType
435474 from google .cloud .proto .spanner .v1 .type_pb2 import STRING , INT64
475+
436476 struct_type_pb = StructType (fields = [
437477 StructType .Field (name = 'name' , type = Type (code = STRING )),
438478 StructType .Field (name = 'age' , type = Type (code = INT64 )),
@@ -444,6 +484,7 @@ def test_non_empty(self):
444484 from google .cloud .proto .spanner .v1 .type_pb2 import Type , StructType
445485 from google .cloud .proto .spanner .v1 .type_pb2 import STRING , INT64
446486 from google .cloud .spanner ._helpers import _make_list_value_pbs
487+
447488 VALUES = [
448489 [u'phred' , 32 ],
449490 [u'bharney' , 31 ],
@@ -462,25 +503,28 @@ class Test_SessionWrapper(unittest.TestCase):
462503
463504 def _getTargetClass (self ):
464505 from google .cloud .spanner ._helpers import _SessionWrapper
506+
465507 return _SessionWrapper
466508
467- def _makeOne (self , session ):
509+ def _make_one (self , session ):
468510 return self ._getTargetClass ()(session )
469511
470512 def test_ctor (self ):
471513 session = object ()
472- base = self ._makeOne (session )
514+ base = self ._make_one (session )
473515 self .assertTrue (base ._session is session )
474516
475517
476518class Test_options_with_prefix (unittest .TestCase ):
477519
478520 def _call_fut (self , * args , ** kw ):
479521 from google .cloud .spanner ._helpers import _options_with_prefix
522+
480523 return _options_with_prefix (* args , ** kw )
481524
482525 def test_wo_kwargs (self ):
483526 from google .gax import CallOptions
527+
484528 PREFIX = 'prefix'
485529 options = self ._call_fut (PREFIX )
486530 self .assertIsInstance (options , CallOptions )
@@ -489,6 +533,7 @@ def test_wo_kwargs(self):
489533
490534 def test_w_kwargs (self ):
491535 from google .gax import CallOptions
536+
492537 PREFIX = 'prefix'
493538 TOKEN = 'token'
494539 options = self ._call_fut ('prefix' , page_token = TOKEN )
0 commit comments