pytest-sugar
pytest-sugar copied to clipboard
Display subtests correctly (and refactored a bit)
Summary
I fixed issue #205 (partially). It now adds additional lines for each subtest, and says exactly what fails. It uses ducktyping to check if subtests are installed, so it shouldn't fail or interfere if not.
I also tried to follow the boy scout rule, and improve readability a bit.
black on it, actually by mistake, however in the changelog I see some inconsistencies in newlines as well as the quotation marks. If this new, blacked, version is inferior I will gladly revert it. I split the changes into two commits as to make it more obvious which is which :)
Example
Results (0.40s):
3 passed
12 failed
- test/test_result.py:24 AssumptionResultTestCase.test_and
- [Both successful]
- [first fail, second succeed]
- [first succeed, second fail]
- [two fail]
- test/test_result.py:41 AssumptionResultTestCase.test_and_chaining
- [combined first]
- [combined last]
- test/test_result.py:53 AssumptionResultTestCase.test_and_none
- test/test_result.py:18 AssumptionResultTestCase.test_empty
- test/test_result.py:66 AssumptionResultTestCase.test_failed_test
- test/test_result.py:60 AssumptionResultTestCase.test_success
- test/test_result.py:85 AssumptionResultBuilderTestCase.test_assuming
- [or_else is empty if clause is True]
- [or_else is not empty if clause is False]
Discussion
I have not added any tests, because tests would (to the best of my knowledge) make pytest-subtest a depedency of this project, which I intend not to do, (Can i make it a dependency only a "test-time"?).
Also i didn't modify the lines prior to the results:
FAILED test/test_result.py::AssumptionResultTestCase::test_and - AttributeError: 'BaseAssumption' object has no attribute 'result'
FAILED test/test_result.py::AssumptionResultTestCase::test_and - AttributeError: 'BaseAssumption' object has no attribute 'result'
FAILED test/test_result.py::AssumptionResultTestCase::test_and - AttributeError: 'BaseAssumption' object has no attribute 'result'
...
Not sure exactly where these are generated, so if you have some tips then please send them my way - i might look more at it tomorrow.
I have not added any tests, because tests would (to the best of my knowledge) make pytest-subtest a depedency of this project, which I intend not to do, (Can i make it a dependency only a "test-time"?).
Our tests have pytest.importorskip("xdist") for xdist related tests and a dependency for tox.ini configuration.
Hey 👋
Thank you for your PR! I am going through the old PRs in this repository and closing them since a long time has passed since the opening and they may not be that relevant anymore. If you still wish to continue with this pull request, let me know and we can re-open it.
Teemu