You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
============================= test session starts ==============================
platform linux -- Python 3.12.2, pytest-8.3.2, pluggy-1.5.0
rootdir: /home/project/data_collect
configfile: pyproject.toml
plugins: syrupy-4.7.1
collected 1 item
tests/test_hello.py F
=================================== FAILURES ===================================
________________________________ test_snapshot _________________________________
snapshot_json = "1000000.6413189545 ± 1.0e+00"
def test_snapshot(snapshot_json):
> assert snapshot_json == pytest.approx(1000000 + random.random())
E assert [- snapshot] == [+ received]
E - "1000000.6413189545 ± 1.0e+00"
E + "1000000.0143782155 ± 1.0e+00"
tests/test_hello.py:13: AssertionError
--------------------------- snapshot report summary ----------------------------
1 snapshot failed.
=========================== short test summary info ============================
FAILED tests/test_hello.py::test_snapshot - assert [- snapshot] == [+ received]
============================== 1 failed in 0.08s ===============================
Finished running tests!
Environment (please complete the following information):
OS: Linux f63999551374 5.14.0-480.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 12 20:45:27 UTC 2024 x86_64 GNU/Linux
Syrupy Version: syrupy-4.7.1
Python Version: 3.12
Additional context
I had to change it to use f"±{d:.6e}" to get it working so that it will serialize it as str. I think maybe for JSON format we can manually override the _filter?
The text was updated successfully, but these errors were encountered:
Describe the bug
When JSONSnapshotExtension is used, pytest.approx no longer works since it serializes the
ApproxScalar
with the original expected value.To reproduce
tests/test_hello.py
, this random should not affect it since default rel1e-6
pytest --snapshot-update
Environment (please complete the following information):
Linux f63999551374 5.14.0-480.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 12 20:45:27 UTC 2024 x86_64 GNU/Linux
Additional context
I had to change it to use
f"±{d:.6e}"
to get it working so that it will serialize it asstr
. I think maybe for JSON format we can manually override the_filter
?The text was updated successfully, but these errors were encountered: