mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Use relative imports in mock and its tests to help backporting (GH-18197)
* asyncio.run only available in 3.8+ * iscoroutinefunction has important bungfixes in 3.8 * IsolatedAsyncioTestCase only available in 3.8+
This commit is contained in:
parent
997443c14c
commit
c7dd3c7d87
3 changed files with 82 additions and 79 deletions
|
@ -1,8 +1,8 @@
|
|||
import asyncio
|
||||
import math
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
from asyncio import iscoroutinefunction
|
||||
from unittest.mock import AsyncMock, Mock, MagicMock, _magics
|
||||
|
||||
|
||||
|
@ -286,8 +286,8 @@ class TestMockingMagicMethods(unittest.TestCase):
|
|||
self.assertEqual(math.trunc(mock), mock.__trunc__())
|
||||
self.assertEqual(math.floor(mock), mock.__floor__())
|
||||
self.assertEqual(math.ceil(mock), mock.__ceil__())
|
||||
self.assertTrue(asyncio.iscoroutinefunction(mock.__aexit__))
|
||||
self.assertTrue(asyncio.iscoroutinefunction(mock.__aenter__))
|
||||
self.assertTrue(iscoroutinefunction(mock.__aexit__))
|
||||
self.assertTrue(iscoroutinefunction(mock.__aenter__))
|
||||
self.assertIsInstance(mock.__aenter__, AsyncMock)
|
||||
self.assertIsInstance(mock.__aexit__, AsyncMock)
|
||||
|
||||
|
@ -312,8 +312,8 @@ class TestMockingMagicMethods(unittest.TestCase):
|
|||
self.assertEqual(math.trunc(mock), mock.__trunc__())
|
||||
self.assertEqual(math.floor(mock), mock.__floor__())
|
||||
self.assertEqual(math.ceil(mock), mock.__ceil__())
|
||||
self.assertTrue(asyncio.iscoroutinefunction(mock.__aexit__))
|
||||
self.assertTrue(asyncio.iscoroutinefunction(mock.__aenter__))
|
||||
self.assertTrue(iscoroutinefunction(mock.__aexit__))
|
||||
self.assertTrue(iscoroutinefunction(mock.__aenter__))
|
||||
self.assertIsInstance(mock.__aenter__, AsyncMock)
|
||||
self.assertIsInstance(mock.__aexit__, AsyncMock)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue