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

Archiver Tests: ArchiverTestCaseBase unittest to pytest conversion #7668

Closed
wants to merge 17 commits into from

Conversation

bigtedde
Copy link
Contributor

@bigtedde bigtedde commented Jun 23, 2023

Most of the tests in the archiver test folder inherit from the ArchiverTestCaseBase in __init__.py, which is all unittest and needs to be converted to pytest. I have begun the process of converting these functions to pytest fixtures in conftest.py. Once these functions have all been converted corrected, I will then be able to go through the archiver test suite folder and begin converting all the tests to use the new pytest fixtures.

conftest.py Outdated


@pytest.fixture(autouse=True)
def archiver_setup(tmp_path):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

names of things are all temporary, will refine later on.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. If a fixture gives back archiver, it can be called like that.😜

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely 👍

Lot's of renaming and refinement to do. Tracer Bullet style for now :)

conftest.py Outdated Show resolved Hide resolved
conftest.py Outdated Show resolved Hide resolved
conftest.py Outdated Show resolved Hide resolved
conftest.py Outdated Show resolved Hide resolved
@bigtedde
Copy link
Contributor Author

bigtedde commented Jun 24, 2023

All functions in archiver folder __init__ have been converted to pytest fixtures now. I've tested most of them, but not all. Will begin converting each test file in archiver folder to use these fixtures and that should bring to light any issues.

@bigtedde
Copy link
Contributor Author

Translated benchmark_cmd, bypass_lock_options, and check_cmd most of the way.



def read_only(path):
pass
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to convert this method still. Will have soon.



def fuse_mount(path, fork, s="", exit_code=EXIT_ERROR):
pass
Copy link
Contributor Author

@bigtedde bigtedde Jun 25, 2023

Choose a reason for hiding this comment

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

Same thing here.

"""runs the same tests, but via the borg binary"""


def fail(s: str):
Copy link
Contributor Author

@bigtedde bigtedde Jun 25, 2023

Choose a reason for hiding this comment

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

Ignore for now, will have this soon.

@bigtedde
Copy link
Contributor Author

Today I converted checks.py, everything works as intended and all tests pass.

@bigtedde
Copy link
Contributor Author

bigtedde commented Jun 28, 2023

Today I converted config_cmd, corruption, debug_cmd, delete_cmd, and diff_cmd tests.

A couple of these tests are failing - something appears wrong with my cmd_fixture. I will work to correct tomorrow.

@bigtedde bigtedde changed the title Archiver folder __init__ to pytest conversion Archiver folder unittest to pytest conversion Jun 28, 2023
@bigtedde
Copy link
Contributor Author

bigtedde commented Jun 30, 2023

After talking with @m3nu, I moved the helper functions from the ArchiverTestCaseBase to a utils module. Previously, I was turning them all into pytest fixtures, which was the incorrect approach. As Manu mentioned - only functions that involve some sort of setup or teardown should be a fixture. The rest of the helper functions are now placed in testsuite/archiver/utils.py, and are imported by the tests as needed.

@bigtedde
Copy link
Contributor Author

This PR is getting bigger then intended, so I will start a new one for each couple of test files that I convert.

@bigtedde
Copy link
Contributor Author

bigtedde commented Jul 3, 2023

For simplicity sake, I reduced this PR to just the changes I made to conftest and testsuite/archiver/__init__.py

I tried to change as little as possible here: Just turned the archiver setup and teardown into a pytest fixture called archiver, and the binary/remote archiver setups to fixtures named accordingly.

@ThomasWaldmann I have a lot of the archiver folder tests already converted to use the pytest fixtures and remove the unittest elements. I will make manageable sized PR's for these tests. Please let me know your thoughts on these changes to conftest and testsuite/archiver/__init__.py as they are the foundation for the rest of the archiver test suite conversion. Thank you!

@bigtedde bigtedde changed the title Archiver folder unittest to pytest conversion ArchiverTestCaseBase to pytest fixture conversion Jul 3, 2023
@bigtedde bigtedde changed the title ArchiverTestCaseBase to pytest fixture conversion Archiver Tests: ArchiverTestCaseBase unittest to pytest conversion Jul 3, 2023
@ThomasWaldmann
Copy link
Member

CI (mypy) for this is still broken, can you fix it?

@bigtedde bigtedde closed this Jul 13, 2023
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.

3 participants