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: use pytest fixtures to reduce repetition in tests #4509

Conversation

Aswinr24
Copy link
Contributor

@Aswinr24 Aswinr24 commented Oct 11, 2024

Description

Refactored the parameter processing test cases to use pytest fixtures and pytest.mark.parametrize to reduce code duplication and improve test maintainability.

Related to #4502

Type of change

  • Code refactor (test improvements to reduce repetition)

Key checklist:

  • No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.42%. Comparing base (3bf3ea8) to head (57597bd).
Report is 178 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4509   +/-   ##
========================================
  Coverage    99.42%   99.42%           
========================================
  Files          299      299           
  Lines        22691    22691           
========================================
  Hits         22560    22560           
  Misses         131      131           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making a start, @Aswinr24! I've added a few suggestions below; please let me know what you think?

tests/unit/test_parameters/test_process_parameter_data.py Outdated Show resolved Hide resolved
tests/unit/test_parameters/test_process_parameter_data.py Outdated Show resolved Hide resolved
tests/unit/test_parameters/test_process_parameter_data.py Outdated Show resolved Hide resolved
tests/unit/test_parameters/test_process_parameter_data.py Outdated Show resolved Hide resolved
tests/unit/test_parameters/test_process_parameter_data.py Outdated Show resolved Hide resolved
tests/unit/test_parameters/test_process_parameter_data.py Outdated Show resolved Hide resolved
@Aswinr24
Copy link
Contributor Author

Thanks for your suggestions, @agriyakhetarpal ! I've made the changes based on your feedback. Let me know if anything else needs tweaking

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @Aswinr24! FYI, I changed the "Fixes" keyword in the PR description to "Related to" since #4502 should include more such files, and we'd like this PR not to close that issue. If you're interested in contributing further, could you open more PRs after this for other cases where we can parametrize tests?

@agriyakhetarpal
Copy link
Member

@all-contributors please add @Aswinr24 for tests

Copy link
Contributor

@agriyakhetarpal

I've put up a pull request to add @Aswinr24! 🎉

@agriyakhetarpal agriyakhetarpal merged commit 3ee7dd0 into pybamm-team:develop Oct 13, 2024
26 checks passed
pkalbhor pushed a commit to pkalbhor/PyBaMM that referenced this pull request Nov 15, 2024
…eam#4509)

* refactor: use pytest fixtures to reduce repetition in tests

* style: pre-commit fixes

* refactor: use pytest fixtures to reduce repetition in tests(v2)

* refactor: use pytest fixtures to reduce repetition in tests(v2)

* refactor: use pytest fixtures to reduce repetition in tests(v2)

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants