-
Notifications
You must be signed in to change notification settings - Fork 15
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
Replace TextTestResult with TestResult for Py3.11 #32
base: master
Are you sure you want to change the base?
Conversation
Thanks for looking into this. I appreciate it! I do slightly prefer seeing the passes and failures reported in the test, but it's not a huge deal.
There is one possibility if you're interested in looking into it: output checkers. They are introduced in the doctest section of the docs: https://pythonhosted.org/manuel/#doctests |
I'll take a look, should have some time this weekend. |
Any updates? |
June 2022 was a while ago, work/life got hectic. I'll read up on the doctests stuff maybe next weekend and see if I can come up with a solution if something hasn't already been committed in the meantime. Unfortunately I may just be busy through May at this point! |
I think this issue has been superseded by recent work. |
Tested this PR and pytest fails form me in + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-manuel-1.12.4-8.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-manuel-1.12.4-8.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network' src/manuel/testcase.py src/manuel/testing.py src/manuel/tests.py
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/manuel-1.12.4
plugins: hypothesis-6.100.0, benchmark-4.0.0, mock-3.14.0, timeout-2.3.1, twisted-1.14.1, tornasync-0.6.0.post2, trio-0.8.0, anyio-4.3.0, asyncio-0.23.7
asyncio: mode=strict
collected 1 item / 1 error
========================================================================================== ERRORS ===========================================================================================
__________________________________________________________________________ ERROR collecting src/manuel/testing.py ___________________________________________________________________________
/usr/lib/python3.10/site-packages/_pytest/runner.py:341: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.10/site-packages/_pytest/runner.py:389: in collect
return list(collector.collect())
/usr/lib/python3.10/site-packages/_pytest/unittest.py:90: in collect
self.session._fixturemanager.parsefactories(self.newinstance(), self.nodeid)
/usr/lib/python3.10/site-packages/_pytest/unittest.py:75: in newinstance
return self.obj("runTest")
E TypeError: TestCase.__init__() missing 2 required positional arguments: 'regions' and 'globs'
===================================================================================== warnings summary ======================================================================================
src/manuel/testing.py:15
/home/tkloczko/rpmbuild/BUILD/manuel-1.12.4/src/manuel/testing.py:15: PytestCollectionWarning: cannot collect test class 'TestCaseMarker' because it has a __init__ constructor (from: src/manuel/testing.py)
class TestCaseMarker:
src/manuel/testing.py:200
/home/tkloczko/rpmbuild/BUILD/manuel-1.12.4/src/manuel/testing.py:200: PytestCollectionWarning: cannot collect test class 'TestFactory' because it has a __init__ constructor (from: src/manuel/testing.py)
class TestFactory:
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
ERROR src/manuel/testing.py::TestCase - TypeError: TestCase.__init__() missing 2 required positional arguments: 'regions' and 'globs'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================== 2 warnings, 1 error in 0.25s ================================================================================ |
Long story short, unittest >= py3.11 returns
test1 (tests.MyTest.test1) ... ok
instead oftest1 (tests.MyTest) ... ok
This PR replaces
unittest.TextTestResult
withunittest.TestResult
which, while not reporting to stdout, still passes the existing metadata check (i.e. expected passes match and expected failures match) and serves to illustrate usage ofunittest
with manuel.I had a bit of a fiddle with this one but couldn't find a way to do a conditional, theoretically something similar to the below would preserve existing behaviour.
If there is a syntax for this that I've missed, please let me know!
Fixes: #30