Skip to content

Commit

Permalink
Fix test checks
Browse files Browse the repository at this point in the history
  • Loading branch information
holtskinner committed Sep 5, 2023
1 parent c843a77 commit ec014f6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Squid(proto.Message):
s = Squid(name="Steve", mass_kg=20)
j = Squid.to_json(s, sort_keys=True)

assert re.match(r"massKg.|\s*name", j)
assert re.match(r"massKg.|\n*name", j)


def test_json_float_precision():
Expand All @@ -192,6 +192,14 @@ class Squid(proto.Message):
mass_kg = proto.Field(proto.FLOAT, number=2)

s = Squid(name="Steve", mass_kg=3.14159265)
j = Squid.to_json(s, float_precision=2)
j = Squid.to_json(s, float_precision=3)

assert j == '{"name":"Steve","massKg":3.14}'
assert (
j
== """
{
"name": "Steve",
"massKg": 3.14
}
"""
)

0 comments on commit ec014f6

Please sign in to comment.