mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
asyncio: Refactor tests: add a base TestCase class
This commit is contained in:
parent
d6f02fc649
commit
c73701de72
13 changed files with 145 additions and 219 deletions
|
@ -37,11 +37,12 @@ def list_to_buffer(l=()):
|
|||
return bytearray().join(l)
|
||||
|
||||
|
||||
class BaseSelectorEventLoopTests(unittest.TestCase):
|
||||
class BaseSelectorEventLoopTests(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
selector = mock.Mock()
|
||||
self.loop = TestBaseSelectorEventLoop(selector)
|
||||
self.set_event_loop(self.loop, cleanup=False)
|
||||
|
||||
def test_make_socket_transport(self):
|
||||
m = mock.Mock()
|
||||
|
@ -597,10 +598,10 @@ class BaseSelectorEventLoopTests(unittest.TestCase):
|
|||
self.loop.remove_writer.assert_called_with(1)
|
||||
|
||||
|
||||
class SelectorTransportTests(unittest.TestCase):
|
||||
class SelectorTransportTests(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.loop = test_utils.TestLoop()
|
||||
self.loop = self.new_test_loop()
|
||||
self.protocol = test_utils.make_test_protocol(asyncio.Protocol)
|
||||
self.sock = mock.Mock(socket.socket)
|
||||
self.sock.fileno.return_value = 7
|
||||
|
@ -684,14 +685,14 @@ class SelectorTransportTests(unittest.TestCase):
|
|||
self.assertEqual(2, sys.getrefcount(self.protocol),
|
||||
pprint.pformat(gc.get_referrers(self.protocol)))
|
||||
self.assertIsNone(tr._loop)
|
||||
self.assertEqual(2, sys.getrefcount(self.loop),
|
||||
self.assertEqual(3, sys.getrefcount(self.loop),
|
||||
pprint.pformat(gc.get_referrers(self.loop)))
|
||||
|
||||
|
||||
class SelectorSocketTransportTests(unittest.TestCase):
|
||||
class SelectorSocketTransportTests(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.loop = test_utils.TestLoop()
|
||||
self.loop = self.new_test_loop()
|
||||
self.protocol = test_utils.make_test_protocol(asyncio.Protocol)
|
||||
self.sock = mock.Mock(socket.socket)
|
||||
self.sock_fd = self.sock.fileno.return_value = 7
|
||||
|
@ -1061,10 +1062,10 @@ class SelectorSocketTransportTests(unittest.TestCase):
|
|||
|
||||
|
||||
@unittest.skipIf(ssl is None, 'No ssl module')
|
||||
class SelectorSslTransportTests(unittest.TestCase):
|
||||
class SelectorSslTransportTests(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.loop = test_utils.TestLoop()
|
||||
self.loop = self.new_test_loop()
|
||||
self.protocol = test_utils.make_test_protocol(asyncio.Protocol)
|
||||
self.sock = mock.Mock(socket.socket)
|
||||
self.sock.fileno.return_value = 7
|
||||
|
@ -1396,10 +1397,10 @@ class SelectorSslWithoutSslTransportTests(unittest.TestCase):
|
|||
_SelectorSslTransport(Mock(), Mock(), Mock(), Mock())
|
||||
|
||||
|
||||
class SelectorDatagramTransportTests(unittest.TestCase):
|
||||
class SelectorDatagramTransportTests(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.loop = test_utils.TestLoop()
|
||||
self.loop = self.new_test_loop()
|
||||
self.protocol = test_utils.make_test_protocol(asyncio.DatagramProtocol)
|
||||
self.sock = mock.Mock(spec_set=socket.socket)
|
||||
self.sock.fileno.return_value = 7
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue