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 more pytest fixtures in modules tests #2226

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

fabianegli
Copy link
Contributor

This PR adds some fixtures to pytest via the conftest.py file in the tests directory. They can then be reused throughout the test suite and as a proof of concept are applied here for some tests of the modules command.

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

@codecov
Copy link

codecov bot commented Mar 29, 2023

Codecov Report

Merging #2226 (a935cae) into dev (27318f1) will increase coverage by 0.04%.
The diff coverage is n/a.

❗ Current head a935cae differs from pull request most recent head fef797d. Consider uploading reports for the commit fef797d to get more accurate results

@@            Coverage Diff             @@
##              dev    #2226      +/-   ##
==========================================
+ Coverage   73.02%   73.06%   +0.04%     
==========================================
  Files          78       78              
  Lines        8384     8384              
==========================================
+ Hits         6122     6126       +4     
+ Misses       2262     2258       -4     

see 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@mirpedrol mirpedrol left a comment

Choose a reason for hiding this comment

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

Looks very good :)
Is your idea to move all tests to using fixtures before merging? Or would you rather start with this as a POC?



@pytest.fixture
def local_modules_repo(modules_repo_dummy, tmp_dir, pipeline_dir):
Copy link
Member

Choose a reason for hiding this comment

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

We will probably need to split it into separate fixtures. For the tests you have implemented we only need the modules repo, but for example to test installing modules we will need the installation objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. But normally I try to go a step as small as possible. Splitting it up will be a later step when it is needed.

tests/conftest.py Outdated Show resolved Hide resolved
tests/test_modules/test_bump_versions.py Outdated Show resolved Hide resolved
fabianegli and others added 2 commits April 24, 2023 13:04
Co-authored-by: Júlia Mir Pedrol <mirp.julia@gmail.com>
Co-authored-by: Júlia Mir Pedrol <mirp.julia@gmail.com>
@fabianegli fabianegli added the WIP Work in progress label Apr 24, 2023
@fabianegli
Copy link
Contributor Author

I would start small and go step by step to gain experience with the fixtures in relation to side effects created by tools and git. Otherwise we'll end up with a big PR and if possible I'd like to avoid that.

@fabianegli
Copy link
Contributor Author

I added the WIP label, because it doesn't yet behave as I initially expected it to. While the return values of fixtures are fixed, side effects are not. There needs to be some other handling of this. I was lately looking into in-memory file systems to see if we could speed up by caching repo states in memory to speed up tests, but I haven't had the spare time required to investigate the options. One specific idea is to use pytest-pyfakefs.

@mirpedrol
Copy link
Member

sounds good! will have a look to pyfakefs, thanks :)

@mirpedrol mirpedrol mentioned this pull request Apr 26, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants