diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index daa8afeec55..7c9afd9f39f 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -210,13 +210,12 @@ class BaseThreadedNetworkedTests(unittest.TestCase): @contextmanager def reaped_pair(self, hdlr): - server, thread = self.make_server((support.HOST, 0), hdlr) - client = self.imap_class(*server.server_address) - try: - yield server, client - finally: - client.logout() - self.reap_server(server, thread) + with self.reaped_server(hdlr) as server: + client = self.imap_class(*server.server_address) + try: + yield server, client + finally: + client.logout() @reap_threads def test_connect(self):