dbt-labs / dbt-labs/dbt

[Feature] Support epsilon / tolerance for float values in unit test expected values.

Open
#10,470 11 comments 0 reactions 0 assignees View on GitHub
engine:v1 resolution:wontfix status:triage type:feature unit tests
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

### Is this your first time submitting a feature request?

- [X] I have read the [expectations for open source contributors](https://docs.getdbt.com/docs/contributing/oss-expectations)
- [X] I have searched the existing issues, and I could not find an existing issue for this feature
- [X] I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

### Describe the feature

When writing expected values in unit tests, some values I'd like to validate are floats. Like other test frameworks, I'd like to have the option to allow some wiggle room with float comparison.

### Describe alternatives you've considered

It seems like I can put the full printed precision in my expected values (ex: `0.0005137135810924898`), however this is verbose, I think it will be brittle, and also doesn't really represent what I want to require of the output.

### Who will this benefit?

Anyone using unit tests and processing numeric data.

### Are you interested in contributing this feature?

_No response_

### Anything else?

This could be similar to [pytest.approx](https://docs.pytest.org/en/latest/reference/reference.html#pytest.approx) or the `rtol` and `atol` arguments to [pandas.testing.assert_frame_equal](https://pandas.pydata.org/docs/reference/api/pandas.testing.assert_frame_equal.html).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.