-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
test_asyncio fails when run under -O #68007
Comments
Ton of failures along the lines of: ====================================================================== Traceback (most recent call last):
File "/Users/bcannon/Repositories/cpython/default/Lib/test/test_asyncio/test_unix_events.py", line 329, in setUp
self.loop = self.new_test_loop()
File "/Users/bcannon/Repositories/cpython/default/Lib/asyncio/test_utils.py", line 413, in new_test_loop
self.set_event_loop(loop)
File "/Users/bcannon/Repositories/cpython/default/Lib/asyncio/test_utils.py", line 407, in set_event_loop
events.set_event_loop(None)
File "/Users/bcannon/Repositories/cpython/default/Lib/asyncio/events.py", line 581, in set_event_loop
get_event_loop_policy().set_event_loop(loop)
AttributeError: 'object' object has no attribute 'set_event_loop' |
-O disables assertions, and asyncio has a ton of assertions. Some tests maybe rely on them? I guess that they are real bugs (assert must be replaced with a regular if+raise) in the middle of the failures. |
This issue is still relevant 4 years later: many test_asyncio tests fail with python3 -O :-( |
I'm sure there's more to it, but I found at least this failure: ~/cpython$ ./python.exe -O -m test test_asyncio -m test_set_event_loop
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 2.02 Run tests sequentially
0:00:00 load avg: 2.02 [1/1] test_asyncio
test test_asyncio failed -- Traceback (most recent call last):
File "/Users/guido/cpython/Lib/test/test_asyncio/test_events.py", line 2595, in test_set_event_loop
self.assertRaises(AssertionError, policy.set_event_loop, object())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: AssertionError not raised by set_event_loop test_asyncio failed (1 failure) == Tests result: FAILURE == 1 test failed: Total duration: 134 ms Also this one: ~/cpython$ ./python.exe -O -m test test_asyncio -m test_create_datagram_endpoint_addr_error
0:00:00 load avg: 2.19 Run tests sequentially
0:00:00 load avg: 2.19 [1/1] test_asyncio
test test_asyncio failed -- Traceback (most recent call last):
File "/Users/guido/cpython/Lib/test/test_asyncio/test_base_events.py", line 1593, in test_create_datagram_endpoint_addr_error
self.assertRaises(
^^^^^^^^^^^^^^^^^^
File "/Users/guido/cpython/Lib/unittest/case.py", line 734, in assertRaises
return context.handle('assertRaises', args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/guido/cpython/Lib/unittest/case.py", line 218, in handle
callable_obj(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/guido/cpython/Lib/asyncio/base_events.py", line 637, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/guido/cpython/Lib/asyncio/base_events.py", line 1287, in create_datagram_endpoint
infos = await self._ensure_resolved(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/guido/cpython/Lib/asyncio/base_events.py", line 1369, in _ensure_resolved
info = _ipaddr_info(host, port, family, type, proto, *address[2:])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: _ipaddr_info() takes from 5 to 7 positional arguments but 12 were given test_asyncio failed (1 error) == Tests result: FAILURE == 1 test failed: Total duration: 165 ms I think calling assertRaises(AssertionError, ...) is definitely an anti-pattern. We can't remove all assertions from the asyncio library, but I think the ones that are explicitly checked for by the tests should go, at least. (Probably replaced with TypeError or ValueError in most cases.) |
I'd be happy to mentor someone who wants to tackle this. |
I would like to tackle this, I'll work on this from next week. |
Is anything left to do? |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: