| Total Complexity | 5 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from unittest import mock |
||
| 2 | from unittest.mock import Mock |
||
| 3 | |||
| 4 | import pytest |
||
| 5 | |||
| 6 | |||
| 7 | async def _fake_async(_): |
||
| 8 | return "mocked" |
||
| 9 | |||
| 10 | |||
| 11 | @mock.patch("tests.bug_fixes.resources_for_189.a_bound_function", lambda _: "mocked") |
||
| 12 | def test_a_bound_function_can_be_mocked(): |
||
| 13 | from tests.bug_fixes.resources_for_189 import a_bound_function |
||
| 14 | from tests.test_context_based_executions import SomeDep |
||
| 15 | |||
| 16 | assert a_bound_function(SomeDep()) == "mocked" |
||
| 17 | |||
| 18 | |||
| 19 | @mock.patch("tests.bug_fixes.resources_for_189.an_async_bound_function", _fake_async) |
||
| 20 | @pytest.mark.asyncio |
||
| 21 | async def test_an_async_bound_function_can_be_mocked(): |
||
| 22 | from tests.bug_fixes.resources_for_189 import an_async_bound_function |
||
| 23 | from tests.test_context_based_executions import SomeDep |
||
| 24 | |||
| 25 | assert await an_async_bound_function(SomeDep()) == "mocked" |
||
| 26 | |||
| 27 | |||
| 28 | @pytest.mark.asyncio |
||
| 29 | async def test_autospec_for_async_bound_function(): |
||
| 30 | from tests.bug_fixes.resources_for_189 import an_async_bound_function |
||
| 31 | |||
| 32 | mock = Mock(spec=an_async_bound_function) |
||
| 33 | assert mock |
||
| 34 |