149149 UnicodeTextTest as _UnicodeTextTest ,
150150 _UnicodeFixture as __UnicodeFixture ,
151151) # noqa: F401, F403
152- from test ._helpers import get_db_url , get_project
152+ from test ._helpers import (
153+ get_db_url ,
154+ get_project ,
155+ )
153156
154157config .test_schema = ""
155158
@@ -162,7 +165,7 @@ class BooleanTest(_BooleanTest):
162165 def test_render_literal_bool (self ):
163166 pass
164167
165- def test_render_literal_bool_true (self , literal_round_trip ):
168+ def test_render_literal_bool_true (self , literal_round_trip_spanner ):
166169 """
167170 SPANNER OVERRIDE:
168171
@@ -171,9 +174,9 @@ def test_render_literal_bool_true(self, literal_round_trip):
171174 following insertions will fail with `Row [] already exists".
172175 Overriding the test to avoid the same failure.
173176 """
174- literal_round_trip (Boolean (), [True ], [True ])
177+ literal_round_trip_spanner (Boolean (), [True ], [True ])
175178
176- def test_render_literal_bool_false (self , literal_round_trip ):
179+ def test_render_literal_bool_false (self , literal_round_trip_spanner ):
177180 """
178181 SPANNER OVERRIDE:
179182
@@ -182,7 +185,7 @@ def test_render_literal_bool_false(self, literal_round_trip):
182185 following insertions will fail with `Row [] already exists".
183186 Overriding the test to avoid the same failure.
184187 """
185- literal_round_trip (Boolean (), [False ], [False ])
188+ literal_round_trip_spanner (Boolean (), [False ], [False ])
186189
187190 @pytest .mark .skip ("Not supported by Cloud Spanner" )
188191 def test_whereclause (self ):
@@ -2003,6 +2006,9 @@ def test_huge_int_auto_accommodation(self, connection, intvalue):
20032006 intvalue ,
20042007 )
20052008
2009+ def test_literal (self , literal_round_trip_spanner ):
2010+ literal_round_trip_spanner (Integer , [5 ], [5 ])
2011+
20062012
20072013class _UnicodeFixture (__UnicodeFixture ):
20082014 @classmethod
@@ -2189,6 +2195,19 @@ def test_dont_truncate_rightside(
21892195 args [1 ],
21902196 )
21912197
2198+ def test_literal (self , literal_round_trip_spanner ):
2199+ # note that in Python 3, this invokes the Unicode
2200+ # datatype for the literal part because all strings are unicode
2201+ literal_round_trip_spanner (String (40 ), ["some text" ], ["some text" ])
2202+
2203+ def test_literal_quoting (self , literal_round_trip_spanner ):
2204+ data = """some 'text' hey "hi there" that's text"""
2205+ literal_round_trip_spanner (String (40 ), [data ], [data ])
2206+
2207+ def test_literal_backslashes (self , literal_round_trip_spanner ):
2208+ data = r"backslash one \ backslash two \\ end"
2209+ literal_round_trip_spanner (String (40 ), [data ], [data ])
2210+
21922211
21932212class TextTest (_TextTest ):
21942213 @classmethod
@@ -2224,6 +2243,21 @@ def test_text_empty_strings(self, connection):
22242243 def test_text_null_strings (self , connection ):
22252244 pass
22262245
2246+ def test_literal (self , literal_round_trip_spanner ):
2247+ literal_round_trip_spanner (Text , ["some text" ], ["some text" ])
2248+
2249+ def test_literal_quoting (self , literal_round_trip_spanner ):
2250+ data = """some 'text' hey "hi there" that's text"""
2251+ literal_round_trip_spanner (Text , [data ], [data ])
2252+
2253+ def test_literal_backslashes (self , literal_round_trip_spanner ):
2254+ data = r"backslash one \ backslash two \\ end"
2255+ literal_round_trip_spanner (Text , [data ], [data ])
2256+
2257+ def test_literal_percentsigns (self , literal_round_trip_spanner ):
2258+ data = r"percent % signs %% percent"
2259+ literal_round_trip_spanner (Text , [data ], [data ])
2260+
22272261
22282262class NumericTest (_NumericTest ):
22292263 @testing .fixture
@@ -2254,7 +2288,7 @@ def run(type_, input_, output, filter_=None, check_scale=False):
22542288 return run
22552289
22562290 @emits_warning (r".*does \*not\* support Decimal objects natively" )
2257- def test_render_literal_numeric (self , literal_round_trip ):
2291+ def test_render_literal_numeric (self , literal_round_trip_spanner ):
22582292 """
22592293 SPANNER OVERRIDE:
22602294
@@ -2263,14 +2297,14 @@ def test_render_literal_numeric(self, literal_round_trip):
22632297 following insertions will fail with `Row [] already exists".
22642298 Overriding the test to avoid the same failure.
22652299 """
2266- literal_round_trip (
2300+ literal_round_trip_spanner (
22672301 Numeric (precision = 8 , scale = 4 ),
22682302 [decimal .Decimal ("15.7563" )],
22692303 [decimal .Decimal ("15.7563" )],
22702304 )
22712305
22722306 @emits_warning (r".*does \*not\* support Decimal objects natively" )
2273- def test_render_literal_numeric_asfloat (self , literal_round_trip ):
2307+ def test_render_literal_numeric_asfloat (self , literal_round_trip_spanner ):
22742308 """
22752309 SPANNER OVERRIDE:
22762310
@@ -2279,13 +2313,13 @@ def test_render_literal_numeric_asfloat(self, literal_round_trip):
22792313 following insertions will fail with `Row [] already exists".
22802314 Overriding the test to avoid the same failure.
22812315 """
2282- literal_round_trip (
2316+ literal_round_trip_spanner (
22832317 Numeric (precision = 8 , scale = 4 , asdecimal = False ),
22842318 [decimal .Decimal ("15.7563" )],
22852319 [15.7563 ],
22862320 )
22872321
2288- def test_render_literal_float (self , literal_round_trip ):
2322+ def test_render_literal_float (self , literal_round_trip_spanner ):
22892323 """
22902324 SPANNER OVERRIDE:
22912325
@@ -2294,7 +2328,7 @@ def test_render_literal_float(self, literal_round_trip):
22942328 following insertions will fail with `Row [] already exists".
22952329 Overriding the test to avoid the same failure.
22962330 """
2297- literal_round_trip (
2331+ literal_round_trip_spanner (
22982332 Float (4 ),
22992333 [decimal .Decimal ("15.7563" )],
23002334 [15.7563 ],
0 commit comments