Optimize BaseSelector.modify(). Patch by Arnaud Faure.

This commit is contained in:
Guido van Rossum 2013-11-07 08:39:28 -08:00
parent b7038817fe
commit d0786a1a50
2 changed files with 16 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import socket
from test import support
from time import sleep
import unittest
import unittest.mock
try:
from time import monotonic as time
except ImportError:
@ -124,6 +125,15 @@ class BaseSelectorTestCase(unittest.TestCase):
# modify unknown file obj
self.assertRaises(KeyError, s.modify, 999999, selectors.EVENT_READ)
# modify use a shortcut
d3 = object()
s.register = unittest.mock.Mock()
s.unregister = unittest.mock.Mock()
s.modify(rd, selectors.EVENT_READ, d3)
self.assertFalse(s.register.called)
self.assertFalse(s.unregister.called)
def test_close(self):
s = self.SELECTOR()
self.addCleanup(s.close)