This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_telnetlib augmentation
Type: behavior Stage: patch review
Components: Tests Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: jackdied Nosy List: benjamin.peterson, georg.brandl, jackdied
Priority: normal Keywords: patch

Created on 2009-04-05 01:46 by jackdied, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_telnetlib.patch jackdied, 2009-04-05 23:17
Messages (10)
msg85460 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-04-05 01:45
The first part of my telnetlib work is testing what already is. 
Attached is a patch to test_telnetlib that tests mosts of the guarantees
of the telnetlib.Telnet.read_* methods (as guaranteed by the docs, at
least).

Theoretically every test I added has a race condition.
ReadTests.blocking_timeout is currently set to 0.1 seconds and works on
my platform (it also works at 0.0 seconds).  Is this acceptable or do I
need to include semaphores will 100% predictable behavior?

TIA
msg85469 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-05 09:03
FWIW, it works here too with 0.0 and 0.1 seconds (it's Linux x86).
msg85584 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-04-05 23:17
added some tests for testing IAC commands and SB data handling.
msg85606 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-04-06 02:09
committed in r71302
msg85716 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-04-07 15:28
Jack, this test seems to be very flaky on the buildbots (and my
machine). I see a lot of failures like this:

======================================================================
FAIL: test_read_eager_B (test.test_telnetlib.ReadTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/temp/python/trunk/Lib/test/test_telnetlib.py", line 235, in
test_read_eager_B
    self._test_read_any_eager_B('read_eager')
  File "/temp/python/trunk/Lib/test/test_telnetlib.py", line 224, in
_test_read_any_eager_B
    self.assertRaises(EOFError, func)
AssertionError: EOFError not raised

======================================================================
FAIL: test_read_very_eager_B (test.test_telnetlib.ReadTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/temp/python/trunk/Lib/test/test_telnetlib.py", line 231, in
test_read_very_eager_B
    self._test_read_any_eager_B('read_very_eager')
  File "/temp/python/trunk/Lib/test/test_telnetlib.py", line 224, in
_test_read_any_eager_B
    self.assertRaises(EOFError, func)
AssertionError: EOFError not raised

----------------------------------------------------------------------
Ran 22 tests in 76.712s

FAILED (failures=2)
test test_telnetlib failed -- errors occurred; run in verbose mode for
details
1 test failed:
    test_telnetlib
msg85732 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-04-07 18:30
Could you try increasing self.blocking_timeout (in the _setUp function)
to something greater than 0.0 (like 0.1) and see if that works?  I
picked a constant that was as small as Worked For Me to keep the total
test time as short as possible.

Unfortunately select() is called in the guts of Telnet so slipping in a
mock object is difficult.  I could also add more synchronization
primitives but that is also icky.  Hopefully just upping the constant a
little does the trick.
msg85736 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-04-07 19:18
2009/4/7 Jack Diederich <report@bugs.python.org>:
>
> Jack Diederich <jackdied@gmail.com> added the comment:
>
> Could you try increasing self.blocking_timeout (in the _setUp function)
> to something greater than 0.0 (like 0.1) and see if that works?  I
> picked a constant that was as small as Worked For Me to keep the total
> test time as short as possible.

Nope, still have the same problem.

>
> Unfortunately select() is called in the guts of Telnet so slipping in a
> mock object is difficult.  I could also add more synchronization
> primitives but that is also icky.  Hopefully just upping the constant a
> little does the trick.

You could monkey patch select.select() during the tests or rewrite
telnetlib, so it calls self._select() and make a subclass.
msg85744 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-04-07 20:23
committed some changes in r71377.  This uses Queue.join() to [hopefully]
eliminate the race condidtions.
msg85751 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-04-07 22:15
2009/4/7 Jack Diederich <report@bugs.python.org>:
>
> Jack Diederich <jackdied@gmail.com> added the comment:
>
> committed some changes in r71377.  This uses Queue.join() to [hopefully]
> eliminate the race condidtions.

Thanks! Works like a charm now.
msg85754 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-04-07 22:34
except when it doesn't!  Still failing on some buildbots.  The couple
places where it expects 1% wibble in timing is far too strict.  I'm
fixing it.
History
Date User Action Args
2022-04-11 14:56:47adminsetgithub: 49946
2009-04-07 22:34:47jackdiedsetmessages: + msg85754
2009-04-07 22:15:31benjamin.petersonsetmessages: + msg85751
2009-04-07 20:23:57jackdiedsetmessages: + msg85744
2009-04-07 19:18:56benjamin.petersonsetmessages: + msg85736
2009-04-07 18:30:08jackdiedsetmessages: + msg85732
2009-04-07 15:28:18benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg85716
2009-04-06 02:09:47jackdiedsetstatus: open -> closed
resolution: accepted
messages: + msg85606
2009-04-05 23:20:04jackdiedsetstage: patch review
type: behavior
components: + Tests
versions: + Python 3.1, Python 2.7
2009-04-05 23:18:40jackdiedsetfiles: - test_telnetlib.patch
2009-04-05 23:18:03jackdiedsetfiles: + test_telnetlib.patch

messages: + msg85584
2009-04-05 09:03:36georg.brandlsetnosy: + georg.brandl
messages: + msg85469
2009-04-05 01:46:01jackdiedcreate