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

Use pytest's fixtures to reduce repetition across tests #4502

Open
prady0t opened this issue Oct 9, 2024 · 5 comments
Open

Use pytest's fixtures to reduce repetition across tests #4502

prady0t opened this issue Oct 9, 2024 · 5 comments
Assignees
Labels
difficulty: easy A good issue for someone new. Can be done in a few hours

Comments

@prady0t
Copy link
Contributor

prady0t commented Oct 9, 2024

Pytest offers various features, one of them being the use of fixtures. This helps us better manage the tests and setup preconditions. Using the pytest.mark.parameterize fixture helps us give multiple inputs to test functions.
Learn more : https://docs.pytest.org/en/stable/how-to/parametrize.html.

We can take for example

        assert isinstance(processed[1][0][0], np.ndarray)
        assert isinstance(processed[1][0][1], np.ndarray)
        assert isinstance(processed[1][1], np.ndarray)

inside a fixture and work up things accordingly.

@prady0t
Copy link
Contributor Author

prady0t commented Oct 9, 2024

@agriyakhetarpal We can put this for hacktoberfest.

@prady0t prady0t changed the title Use parameterize pytest's fixture to reduce repetetion inside tests/unit/test_parameters/test_process_parameter_data.py file. Use pytest's fixture to reduce repetetion inside tests/unit/test_parameters/test_process_parameter_data.py file. Oct 9, 2024
@agriyakhetarpal agriyakhetarpal added difficulty: easy A good issue for someone new. Can be done in a few hours hacktoberfest labels Oct 9, 2024
@agriyakhetarpal
Copy link
Member

I added the labels – additionally, could you please link to some code examples (a few low-hanging fruits) where you've noticed that this is the case, so that it's easier for potential contributors to know what to start with?

@Aswinr24
Copy link
Contributor

Hey would love to pick up this issue !
I understand that we must set up fixtures to handle multiple cases here and thereby consolidating tests for different inputs into a single, reusable function, therefore making the code more concise.
Can I start working on this ?

@arjxn-py
Copy link
Member

Sure @Aswinr24, feel free to work on this and also don't hesitate to let us know if you need help at any point :)

@Aswinr24
Copy link
Contributor

Could You Please Review my PR and suggest if any changes are required

@agriyakhetarpal agriyakhetarpal changed the title Use pytest's fixture to reduce repetetion inside tests/unit/test_parameters/test_process_parameter_data.py file. Use pytest's fixtures to reduce repetition across tests Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy A good issue for someone new. Can be done in a few hours
Projects
None yet
Development

No branches or pull requests

4 participants