-
Notifications
You must be signed in to change notification settings - Fork 1.1k
- show traceback when test failed #419
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
Open
maho
wants to merge
4
commits into
micropython:master
Choose a base branch
from
maho:unittest-exception
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
Is this the same as what CPython does? |
Let's check: test_ee.py import unittest
class MyTestCase(unittest.TestCase):
def _fn2(self):
raise Exception("this shouldn't happend, but it did")
def _fn(self):
return self._fn2()
def test_exception(self):
self._fn()
if __name__ == '__main__':
unittest.main()
micropython: % micropython test_ee.py :( 1 21-04-25 - 17:39:17
test_exception (MyTestCase) ... FAIL
Traceback (most recent call last):
File "/home/maho/workspace/servo/dispenser/.micropython-lib/unittest/unittest.py", line 201, in run_class
File "test_ee.py", line 13, in test_exception
File "test_ee.py", line 9, in _fn
File "test_ee.py", line 6, in _fn2
Exception: this shouldn't happend, but it did
Ran 1 tests
FAILED (failures=1, errors=0) CPython 3.8: % python3 /tmp/test_ee.py :( 1 21-04-25 - 17:39:23
E
======================================================================
ERROR: test_exception (__main__.MyTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test_ee.py", line 13, in test_exception
self._fn()
File "/tmp/test_ee.py", line 9, in _fn
return self._fn2()
File "/tmp/test_ee.py", line 6, in _fn2
raise Exception("this shouldn't happend, but it did")
Exception: this shouldn't happend, but it did
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1) So this change makes it closer to behaviour of CPython. |
Makes sense. Adding a newline would be nice though because raising multiple exceptions results in text which gets hard to read. |
stinos
reviewed
Apr 26, 2021
stinos
reviewed
Apr 26, 2021
stinos
reviewed
Apr 26, 2021
6161049
to
acd64a6
Compare
stinos
reviewed
Apr 28, 2021
should I do any more changes or it's ok? |
@stinos? Anyone? |
I think this is ok, but it's not up to me to merge it :) |
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.
i was surprised that exception in tested function is just silently redirected to nowhere.
I think it's good to show the traceback.