mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Optimize BaseSelector.modify(). Patch by Arnaud Faure.
This commit is contained in:
parent
b7038817fe
commit
d0786a1a50
2 changed files with 16 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue