-
Notifications
You must be signed in to change notification settings - Fork 42
How to implement assertions with a tolerance #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sorry about the delayed response, I didn't even realize we had discussions enabled 😓. We have notifications setup for new issues, but nothing watching the discussions. I believe the author of #438 was trying to do the same sort of assertion as you describe just using pytest.approx instead. There are some suggestions and workarounds in that issue. Please let me know if there are any follow up questions. In terms of that specific syntax, it's not possible with the latest syrupy, though it's interesting and may warrant further investigation. What would the underlying snapshot look like? Originally posted by @noahnu in #537 (comment) |
I would assume a snapshot would just contain a number, which would be the 100% baseline. When running the test, it should match with a provided tolerance. I don't really know what would be a good syntax for that, but I suppose anything will work as long it does what's needed. Originally posted by @rassie in #537 (reply in thread) |
The difficulty is that we only serialize data. We don't currently support deserialization. So we do a character by character match on the serialized data. This ensures the snapshots are 100% deterministic (unlike snapshottest which writes python that can include memory addresses for example and thus produce inconsistent results between snapshots). Originally posted by @noahnu in #537 (reply in thread) |
Discussed in #537
Originally posted by rassie August 4, 2021
I would like to implement this assertion to check that
count
is within 10% of the expected value:Is there a good way to do that with
syrupy
?The text was updated successfully, but these errors were encountered: