Support @expectedFailure in unittest#1139
Open
Josverl wants to merge 2 commits into
Open
Conversation
3d81359 to
005e402
Compare
Contributor
Author
|
Found a refactor to save 71 bytes; now at +342 B (8.3% → 6.9%) There are a few more options ; reduce the ClassNames names to be shorter but more cryptic would save ~24 bytes. |
Includes unittest for the new functionality. Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
0e7891b to
207bfd4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I have found that in testing MicroPython it is sometimes hard to keep track of what is correct for Python, and what is correct for MicroPython.
We want the CI to remain green - to detect and avoid regressiobns, and MicroPython small , and close to CPython.
In MicroPython tests that means that we sometimes need to test for not CPython behaviour.
That can be done with
.expfiles for non-unittest files.CPython's unittest has a
@unittest.expectedFailuredecorator that can be used to differentiate between:Note
This differentiation is not magically inserted , the test code still needs to be good.
I have used this approach when running matrix tests against the different typing implementations, one example where it was clear that a 100% CPython compatibility was a non-goal.
By decorating some tests with
@unittest.expectedFailurea much cleared report can be built on the capabilities and correctness for both MicroPython and CPython.This PR implements this directly as part of the unittest module to keep usage as simple as possible.
impact on size
Measured with mpy-cross -O3 (v1.27, mpy v6.3), using the same source filename for a fair comparison:
Testing
Added test to test the unitest.
Trade-offs and Alternatives
This is an alternative implementation to PR #1133
Generative AI
I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.