Commit 77bc04a3 authored by Yury Selivanov's avatar Yury Selivanov

asyncio: Fix NameError in sslproto _fatal_error()

Patch by Richard Walker.
parent 2e4cdb67
......@@ -5,6 +5,7 @@ try:
except ImportError: # pragma: no cover
ssl = None
from . import base_events
from . import compat
from . import protocols
from . import transports
......
"""Tests for asyncio/sslproto.py."""
import logging
import unittest
from unittest import mock
try:
......@@ -8,6 +9,7 @@ except ImportError:
ssl = None
import asyncio
from asyncio import log
from asyncio import sslproto
from asyncio import test_utils
......@@ -66,6 +68,20 @@ class SslProtoHandshakeTests(test_utils.TestCase):
test_utils.run_briefly(self.loop)
self.assertIsInstance(waiter.exception(), ConnectionResetError)
def test_fatal_error_no_name_error(self):
# From issue #363.
# _fatal_error() generates a NameError if sslproto.py
# does not import base_events.
waiter = asyncio.Future(loop=self.loop)
ssl_proto = self.ssl_protocol(waiter)
# Temporarily turn off error logging so as not to spoil test output.
log_level = log.logger.getEffectiveLevel()
log.logger.setLevel(logging.FATAL)
try:
ssl_proto._fatal_error(None)
finally:
# Restore error logging.
log.logger.setLevel(log_level)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment