Skip to content

Commit

Permalink
Use Decimal for parsing JSON to mitigate precision problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Argmaster committed Jun 7, 2024
1 parent b4f239d commit 2806754
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/gerberx3/test_assets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import decimal
import json
from dataclasses import dataclass

Expand Down Expand Up @@ -182,8 +183,12 @@ def test_parser2(asset: Asset, config: Config) -> None:
".parser2", asset.relative_path
).with_suffix(".json")

output_file_content = json.loads(output_file_path.read_text())
reference_file_content = json.loads(reference_path.read_text())
output_file_content = json.loads(
output_file_path.read_text(), parse_float=decimal.Decimal
)
reference_file_content = json.loads(
reference_path.read_text(), parse_float=decimal.Decimal
)

assert output_file_content == reference_file_content

Expand Down

0 comments on commit 2806754

Please sign in to comment.