asynctest icon indicating copy to clipboard operation
asynctest copied to clipboard

Test case failures in Python 3.8

Open tirkarthi opened this issue 6 years ago • 3 comments

There are some test failures in CPython master and also 3.8 beta 1. I guess the CI could be using an older version of 3.8. I tried some bisecting and on reverting changes made in https://bugs.python.org/issue36996 some cases are fixed. Recently unittest.mock.patch has support added for async functions to be mocked. I am not sure if asynctest tests needs to be changed or if there is a regression due to the linked CPython issue. I have filed DeprecationWarnings in Python 3.8 under #126 since it's of low priority. Test run log as below.

Thanks for asynctest that helped in AsyncMock design :)

python -Wignore -m unittest test
......................................F..E..................................................................................................................................................................................
======================================================================
ERROR: test_create_autospec_on_coroutine_and_using_assert_methods (test.test_mock.Test_CoroutineMock_awaited)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/karthi/asynctest/asynctest/case.py", line 297, in run
    self._run_test_method(testMethod)
  File "/home/karthi/asynctest/asynctest/case.py", line 354, in _run_test_method
    self.loop.run_until_complete(result)
  File "/home/karthi/asynctest/asynctest/case.py", line 224, in wrapper
    return method(*args, **kwargs)
  File "/home/karthi/cpython/Lib/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "/home/karthi/asynctest/test/test_mock.py", line 776, in test_create_autospec_on_coroutine_and_using_assert_methods
    yield from mock("arg0", "arg1", "arg2")
TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator

======================================================================
FAIL: test_awaited_from_autospec_mock (test.test_mock.Test_CoroutineMock_awaited)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/karthi/asynctest/asynctest/case.py", line 297, in run
    self._run_test_method(testMethod)
  File "/home/karthi/asynctest/asynctest/case.py", line 354, in _run_test_method
    self.loop.run_until_complete(result)
  File "/home/karthi/asynctest/asynctest/case.py", line 224, in wrapper
    return method(*args, **kwargs)
  File "/home/karthi/cpython/Lib/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "/home/karthi/asynctest/test/test_mock.py", line 571, in test_awaited_from_autospec_mock
    self.assertFalse(mock.a_coroutine.awaited)
AssertionError: <unittest.mock._AwaitEvent object at 0x7f58e9e5e3c0> is not false

======================================================================
FAIL: test_patch_coroutine_with_multiple_scopes (test.test_mock.Test_patch_decorator_coroutine_or_generator_scope) [new style coroutine - Outer: GLOBAL, inner: LIMITED]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/karthi/asynctest/test/test_mock.py", line 1800, in test_patch_coroutine_with_multiple_scopes
    run_coroutine(tester(a_native_coroutine))
  File "/home/karthi/asynctest/test/utils.py", line 9, in run_coroutine
    return loop.run_until_complete(coroutine)
  File "/home/karthi/cpython/Lib/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "/home/karthi/asynctest/test/test_mock.py", line 1764, in tester
    self.assertEqual((True, False), fut.result())
AssertionError: Tuples differ: (True, False) != (True, True)

First differing element 1:
False
True

- (True, False)
+ (True, True)

======================================================================
FAIL: test_patch_coroutine_with_multiple_scopes (test.test_mock.Test_patch_decorator_coroutine_or_generator_scope) [new style coroutine - Outer: LIMITED, inner: GLOBAL]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/karthi/asynctest/test/test_mock.py", line 1811, in test_patch_coroutine_with_multiple_scopes
    run_coroutine(tester(a_native_coroutine))
  File "/home/karthi/asynctest/test/utils.py", line 9, in run_coroutine
    return loop.run_until_complete(coroutine)
  File "/home/karthi/cpython/Lib/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "/home/karthi/asynctest/test/test_mock.py", line 1764, in tester
    self.assertEqual((True, False), fut.result())
AssertionError: Tuples differ: (True, False) != (True, True)

First differing element 1:
False
True

- (True, False)
+ (True, True)

======================================================================
FAIL: test_multiple_patches_on_coroutine (test.test_mock.Test_patch_decorator_coroutine_or_generator_scope_LIMITED) [new style coroutine]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/karthi/asynctest/test/test_mock.py", line 2088, in test_multiple_patches_on_coroutine
    run_coroutine(tester(a_native_coroutine))
  File "/home/karthi/asynctest/test/utils.py", line 9, in run_coroutine
    return loop.run_until_complete(coroutine)
  File "/home/karthi/cpython/Lib/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "/home/karthi/asynctest/test/test_mock.py", line 2063, in tester
    self.assertEqual((False, False), fut.result())
AssertionError: Tuples differ: (False, False) != (True, True)

First differing element 0:
False
True

- (False, False)
+ (True, True)

======================================================================
FAIL: test_patch_coroutine_only_when_running (test.test_mock.Test_patch_decorator_coroutine_or_generator_scope_LIMITED) [new style coroutine]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/karthi/asynctest/test/test_mock.py", line 2036, in test_patch_coroutine_only_when_running
    run_coroutine(tester(a_native_coroutine))
  File "/home/karthi/asynctest/test/utils.py", line 9, in run_coroutine
    return loop.run_until_complete(coroutine)
  File "/home/karthi/cpython/Lib/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "/home/karthi/asynctest/test/test_mock.py", line 2015, in tester
    self.assertFalse(fut.result())
AssertionError: True is not false

----------------------------------------------------------------------
Ran 223 tests in 1.293s

FAILED (failures=5, errors=1)

tirkarthi avatar Jun 29 '19 17:06 tirkarthi

Any progress here? Fedora 32 is going to ship with Python 3.8 and it'd be great to have a package that passes all tests by Beta Freeze latest (late February 2020).

rathann avatar Nov 18 '19 11:11 rathann

Ping. Is this package alive?

mgorny avatar Apr 27 '20 06:04 mgorny

Since AsyncMock landed in Python 3.8, people should use AsyncMock and .

AsyncMock breaks asynctest in ways that make it hard to fix correctly, and I have time/resources to spend on this package.

Maybe we can just remove code related to old-style coroutines and fix most issues, but I can't promise when this will be done.

Le lun. 27 avr. 2020 à 08:34, Michał Górny [email protected] a écrit :

Ping. Is this package alive?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Martiusweb/asynctest/issues/132#issuecomment-619759428, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPWGGCA33XODC2UVNHIBTROURPLANCNFSM4H4K2RIA .

-- Martin http://www.martiusweb.net Richard www.martiusweb.net

Martiusweb avatar Apr 30 '20 08:04 Martiusweb