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

Test function isolation isn't working when using fixture with parameters #1287

Open
pandadefi opened this issue Feb 6, 2023 · 1 comment · May be fixed by #2277
Open

Test function isolation isn't working when using fixture with parameters #1287

pandadefi opened this issue Feb 6, 2023 · 1 comment · May be fixed by #2277
Labels
category: bug Something isn't working

Comments

@pandadefi
Copy link
Contributor

pandadefi commented Feb 6, 2023

Environment information

  • OS: macOS
  • Python Version: 3.9.16
  • ape and plugin versions: 0.6.2

What went wrong?

When running tests, the different tests should run in isolation, including the tests function with @pytest.fixture params. With the latest version of ape, the blockchain isn't reverted to the snapshot between several tests using the different values provided by @pytest.fixture params.

here is an example: https://github.com/yearn/veYFI/pull/220/files#diff-dd59d96f9ab6202cc08431b4f984bd2f6934b6d6bf9c37e8697ee68ad4f6058eR220
Here the first test will pass with no tokens looked in the contract, but this assertion will fail on the second run with the second parameter.

Previous version

I have downgraded to ape version 0.5.9. The issue is the same.

@pandadefi pandadefi added the category: bug Something isn't working label Feb 6, 2023
@pandadefi pandadefi changed the title Test function isolation isn't working when using @pytest.fixture(params=[X, Y, Z]) Test function isolation isn't working when using fixture with parameters Feb 6, 2023
@antazoey
Copy link
Member

antazoey commented Feb 6, 2023

We discovered that parametrized fixtures are not always working correctly, especially in complex setups. However we found that if you change the parametrization to be on the test using pytest.mark.paramtrize(), things work as expected. We are going to look into the issue with parametrized fixture and isolation! Thank you for reporting.

@antazoey antazoey linked a pull request Sep 11, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants