@@ -253,7 +253,10 @@ class Squid(proto.Message):
253253 assert re .search (r"massKg.*name" , j )
254254
255255
256- # TODO: https://github.com/googleapis/proto-plus-python/issues/390
256+ pytest .skipif (
257+ int (proto .message ._PROTOBUF_MAJOR_VERSION ) >= 7 ,
258+ "float_precision removed in protobuf 7.x"
259+ )
257260def test_json_float_precision ():
258261 class Squid (proto .Message ):
259262 name = proto .Field (proto .STRING , number = 1 )
@@ -263,3 +266,21 @@ class Squid(proto.Message):
263266 j = Squid .to_json (s , float_precision = 3 , indent = None )
264267
265268 assert j == '{"name": "Steve", "massKg": 3.14}'
269+
270+ pytest .skipif (
271+ int (proto .message ._PROTOBUF_MAJOR_VERSION ) < 7 ,
272+ "unsupported protobuf version for test"
273+ )
274+ def test_json_float_precision_7_plus ():
275+ class Squid (proto .Message ):
276+ name = proto .Field (proto .STRING , number = 1 )
277+ mass_kg = proto .Field (proto .FLOAT , number = 2 )
278+
279+ s = Squid (name = "Steve" , mass_kg = 3.14159265 )
280+ with pytest .warns (DeprecationWarning ) as warnings :
281+ j = Squid .to_json (s , float_precision = 3 , indent = None )
282+
283+ assert j == '{"name": "Steve", "massKg": 3.14159265}'
284+
285+ assert len (warnings ) == 1
286+ assert "`float_precision` has been removed" in warnings [0 ].message .args [0 ]
0 commit comments