-
Notifications
You must be signed in to change notification settings - Fork 89
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
subtests error in the subTest decorator. #235
Comments
Indeed, it would be nice, Would love it if you wanted to put a patch forward. |
Arguably the bug is in subTest itself - it presumes _outcome exists, but _outcome is a unittest internal attribute that isn't part of the API contract, so we should fix this in CPython's stdlib. |
I agree that unittest should have a fall back, and that the error sucks because of what they are doing. I'll rename this bug. |
Oh, noes, it was you who renamed it. I think my name was better 😄 |
Filed an upstream issue: https://bugs.python.org/issue34900 |
That PR has been merged, so I guess this can now be closed. 👍 |
I'm running in the same error, using Python 3.6.9. The change should be already included in 3.6.8. Simple reproducer:
import testtools
class TC(testtools.TestCase):
def test_subtest(self):
with self.subTest():
pass Output:
|
I'm running into the same thing in 3.8.1.
|
The problem here is testools is using unittest2 [1] library that hasn't desired fix implemented.
[1] https://github.com/testing-cabal/testtools/blob/master/requirements.txt Anyway the above patch is just skipping implementing the feature if |
I'm sure a similar patch to python/cpython#9707 can be applied to |
I am proposing to drop using very old unittest2 library for newer python versions. Such library hasn't changed since 2005 :-( |
unittest2 library isn't been updated since some years. Newer python frameworks are expected to has far more fixes than that unittest2. Actually unittest2 states it is only tested up to python 3.4 This therefore limit the use of unittest2 library up to the last python 3.4 release. It is expected to fix Issue testing-cabal#235
Any version of testtools lower than 2.5.0 fails if the attribute 'result_supports_subtests' is present on any test object because of old unittest support. See also testing-cabal/testtools#235 and testing-cabal/testtools@38fc9a9 for more info. Change-Id: I23a1ca789f4ea4ffd981e1071f3c2c6c333ac330
* Update ironic from branch 'master' to 4339f6f65dbecaf7d38bdb985465fb7c1124b63c - Merge "Bump min version of testtools" - Bump min version of testtools Any version of testtools lower than 2.5.0 fails if the attribute 'result_supports_subtests' is present on any test object because of old unittest support. See also testing-cabal/testtools#235 and testing-cabal/testtools@38fc9a9 for more info. Change-Id: I23a1ca789f4ea4ffd981e1071f3c2c6c333ac330
python's unittest now has a cool feature for test scenarios called subTest: https://docs.python.org/3/library/unittest.html#unittest.TestCase.subTest
I'm trying to update some tests from unittest.TestCase to testtools.TestCase, but there are some that use subTest which blocks me from using testtools.
This is the trace from one of the failing tests:
I think it would be great if testtools supports subTests.
The text was updated successfully, but these errors were encountered: