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

Refactor loops in tests to be parametrized #578

Closed
botanical opened this issue May 16, 2024 · 7 comments
Closed

Refactor loops in tests to be parametrized #578

botanical opened this issue May 16, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@botanical
Copy link
Contributor

Some tests can be updated to use pytest.parametrize, such as https://github.com/nsidc/earthaccess/blob/main/tests/integration/test_auth.py#L83-L98

@mfisher87
Copy link
Collaborator

cc @Sherwin-14

@Sherwin-14
Copy link
Contributor

Hey could I get some more info about this? How can I approach this and what sort of considerations I need to take?

@mfisher87
Copy link
Collaborator

Hey @Sherwin-14, not 100% sure if this answers your question, but we're looking to replace the for loop in the linked test with a @pytest.parametrize decorator as shown in the docs linked in the top-level post. This will increase the total number of tests, but there will be less assertions in each of the affected test. Does this help?

@Sherwin-14
Copy link
Contributor

Hey @Sherwin-14, not 100% sure if this answers your question, but we're looking to replace the for loop in the linked test with a @pytest.parametrize decorator as shown in the docs linked in the top-level post. This will increase the total number of tests, but there will be less assertions in each of the affected test. Does this help?

If I understand correctly, we might need to break these test functions and replace the for loop's with @pytest.parametrize decorator. This would result in 2 tests resulting from one single broken test?

@mfisher87
Copy link
Collaborator

There would still be one test function, but the decorator would allow that test to run multiple times with different parameters, in other words different input data and different expected outputs. With this method, we specify the test logic once in the function, and then represent the different parameters as a data structure that we pass to the @pytest.parametrize decorator.

@Sherwin-14
Copy link
Contributor

@mfisher87 Hey can you assign me this one?

@chuckwondo
Copy link
Collaborator

Fixed by #736

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in earthaccess project Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

4 participants