-
Notifications
You must be signed in to change notification settings - Fork 7
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 testcases to directly use pytest #39
Comments
Fixes #39 by adding the necessary infrastructure for pytest-based test classes and refactoring the "project createbom" testcases to use it. This shows the pytest assert syntax and how to capture stdout with pytest using the "capsys" fixture.
We now have a first pytest-based class in https://github.com/sw360/capycli/blob/main/tests/test_create_bom.py. I would however suggest to keep this issue open for a while until at least some more files have been migrated to pytest and/or we added some sentences to https://github.com/sw360/capycli/blob/main/Contributing.md#testing about the future direction. |
@tngraf, what do you think, do you want to keep both variants (unittest and pytest-based classes) in the long run, so we can choose case by case or should we strive to migrate all tests to pytest over time? |
I did some tests with pytests assert and console output capturing. I agree that these are nice features, but
I will not block someone from using |
Ok, then let's document it like that. |
We already use pytest, but still derive our test classes from traditional unittest.
This is perfectly valid, but we cannot use some nice pytest features that way. As an example, pytest has built-in support for capturing stdout/stderr, so we could drop our own implementation. I also like pytest's more intuitive assert syntax.
Concrete reason why I ask is that I recently extended our own capture_stdout implementation to support an arbitrary number of arguments and now I noticed that with our own implemenation, I can't capture stdout and check the return value at the same time. All of that would already be available from pytest.
It would however mean a larger rework, but I think it would be possible to migrate file by file where needed.
If you're interested, @tngraf, I could try adding my new tests for #33 in pytest-style or also rewrite the "project createbom" tests in #37 to pytest style.
The text was updated successfully, but these errors were encountered: