bpo-43478: Restrict use of Mock objects as specs (GH-25326)

* Restrict using Mock objects as specs as this is always a test bug where the resulting mock is misleadingly useless.
* Skip a broken test that exposes a bug elsewhere in mock (noted in the original issue).
This commit is contained in:
Matthew Suozzo 2021-04-09 23:45:50 -04:00 committed by GitHub
parent ba1db57198
commit dccdc500f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 8 deletions

View file

@ -199,9 +199,9 @@ def test_create_autospec_instance(self):
with self.assertRaises(RuntimeError):
create_autospec(async_func, instance=True)
@unittest.skip('Broken test from https://bugs.python.org/issue37251')
def test_create_autospec_awaitable_class(self):
awaitable_mock = create_autospec(spec=AwaitableClass())
self.assertIsInstance(create_autospec(awaitable_mock), AsyncMock)
self.assertIsInstance(create_autospec(AwaitableClass), AsyncMock)
def test_create_autospec(self):
spec = create_autospec(async_func_args)