Skip to content
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

Easier usage with floats #913

Open
shughes-uk opened this issue Oct 27, 2024 · 2 comments
Open

Easier usage with floats #913

shughes-uk opened this issue Oct 27, 2024 · 2 comments
Labels
feature request New feature or request

Comments

@shughes-uk
Copy link

shughes-uk commented Oct 27, 2024

**Is your feature request related to a problem? Please describe **

We can't use syrupy when we are snapshotting objects with floats in them, due to precision issues.

Describe the solution you'd like

A way to set up a level of precision to match floats, ideally globally for all tests via a config option.

Describe alternatives you've considered

Using custom matchers on an individual attribute basis but thats a giant pain.

Additional context

@noahnu
Copy link
Collaborator

noahnu commented Nov 3, 2024

Using custom matchers on an individual attribute basis but thats a giant pain.

You can use a matcher based on type rather than attribute name.

Regardless, this has come up before. Open to ideas/contributions.

@noahnu noahnu added the feature request New feature or request label Nov 3, 2024
@shughes-uk
Copy link
Author

shughes-uk commented Nov 3, 2024

Using custom matchers on an individual attribute basis but thats a giant pain.

You can use a matcher based on type rather than attribute name.

Regardless, this has come up before. Open to ideas/contributions.

Interesting, I'm not sure i understand the matcher system based on the docs, I came away with the impression it would simply be asserting an attribute had a specific type. I was hoping I could do something like that but failed and was looking at custom serializers.

Ideally i could just drop in the pytest.approx function, i would be happy to make a docs PR with an example of how to do it if you can show me how!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants