Commit 4cae31bd authored by Gregory P. Smith's avatar Gregory P. Smith

one more test fix for systems without select.poll. tested by deleting

select.poll before running.  works both ways (finally).  this should fix
the windows build.
parent adfb73ba
...@@ -169,13 +169,14 @@ class ExpectAndReadTestCase(TestCase): ...@@ -169,13 +169,14 @@ class ExpectAndReadTestCase(TestCase):
def setUp(self): def setUp(self):
self.old_select = select.select self.old_select = select.select
select.select = mock_select select.select = mock_select
self.old_poll = False
if hasattr(select, 'poll'): if hasattr(select, 'poll'):
self.old_poll = select.poll self.old_poll = select.poll
select.poll = MockPoller select.poll = MockPoller
MockPoller.test_case = self MockPoller.test_case = self
def tearDown(self): def tearDown(self):
if hasattr(select, 'poll'): if self.old_poll:
MockPoller.test_case = None MockPoller.test_case = None
select.poll = self.old_poll select.poll = self.old_poll
select.select = self.old_select select.select = self.old_select
...@@ -210,7 +211,8 @@ class ReadTests(ExpectAndReadTestCase): ...@@ -210,7 +211,8 @@ class ReadTests(ExpectAndReadTestCase):
"""Use select.select() to implement telnet.read_until().""" """Use select.select() to implement telnet.read_until()."""
want = [b'x' * 10, b'match', b'y' * 10] want = [b'x' * 10, b'match', b'y' * 10]
telnet = test_telnet(want, use_poll=False) telnet = test_telnet(want, use_poll=False)
select.poll = lambda *_: self.fail('unexpected poll() call.') if self.old_poll:
select.poll = lambda *_: self.fail('unexpected poll() call.')
data = telnet.read_until(b'match') data = telnet.read_until(b'match')
self.assertEqual(data, b''.join(want[:-1])) self.assertEqual(data, b''.join(want[:-1]))
...@@ -428,7 +430,8 @@ class ExpectTests(ExpectAndReadTestCase): ...@@ -428,7 +430,8 @@ class ExpectTests(ExpectAndReadTestCase):
"""Use select.select() to implement telnet.expect().""" """Use select.select() to implement telnet.expect()."""
want = [b'x' * 10, b'match', b'y' * 10] want = [b'x' * 10, b'match', b'y' * 10]
telnet = test_telnet(want, use_poll=False) telnet = test_telnet(want, use_poll=False)
select.poll = lambda *_: self.fail('unexpected poll() call.') if self.old_poll:
select.poll = lambda *_: self.fail('unexpected poll() call.')
(_,_,data) = telnet.expect([b'match']) (_,_,data) = telnet.expect([b'match'])
self.assertEqual(data, b''.join(want[:-1])) self.assertEqual(data, b''.join(want[:-1]))
......
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