Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes | Private Member Functions
test.test_telnetlib.OptionTests Class Reference
Inheritance diagram for test.test_telnetlib.OptionTests:
Inheritance graph
[legend]
Collaboration diagram for test.test_telnetlib.OptionTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_IAC_commands
def test_SB_commands
def test_debuglevel_reads
def test_debuglevel_write
def test_debug_accepts_str_port

Static Public Attributes

list cmds = [tl.AO, tl.AYT, tl.BRK, tl.EC, tl.EL, tl.GA, tl.IP, tl.NOP]

Private Member Functions

def _test_command

Detailed Description

Definition at line 276 of file test_telnetlib.py.


Member Function Documentation

def test.test_telnetlib.OptionTests._test_command (   self,
  data 
) [private]
helper for testing IAC + cmd 

Definition at line 280 of file test_telnetlib.py.

00280 
00281     def _test_command(self, data):
00282         """ helper for testing IAC + cmd """
00283         telnet = test_telnet(data)
00284         data_len = len(b''.join(data))
00285         nego = nego_collector()
00286         telnet.set_option_negotiation_callback(nego.do_nego)
00287         txt = telnet.read_all()
00288         cmd = nego.seen
00289         self.assertTrue(len(cmd) > 0) # we expect at least one command
00290         self.assertIn(cmd[:1], self.cmds)
00291         self.assertEqual(cmd[1:2], tl.NOOPT)
00292         self.assertEqual(data_len, len(txt + cmd))
00293         nego.sb_getter = None # break the nego => telnet cycle

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 346 of file test_telnetlib.py.

00346 
00347     def test_debug_accepts_str_port(self):
00348         # Issue 10695
00349         with test_socket([]):
00350             telnet = TelnetAlike('dummy', '0')
00351             telnet._messages = ''
00352         telnet.set_debuglevel(1)
00353         telnet.msg('test')
00354         self.assertRegex(telnet._messages, r'0.*test')
00355 

Here is the call graph for this function:

Definition at line 320 of file test_telnetlib.py.

00320 
00321     def test_debuglevel_reads(self):
00322         # test all the various places that self.msg(...) is called
00323         given_a_expect_b = [
00324             # Telnet.fill_rawq
00325             (b'a', ": recv b''\n"),
00326             # Telnet.process_rawq
00327             (tl.IAC + bytes([88]), ": IAC 88 not recognized\n"),
00328             (tl.IAC + tl.DO + bytes([1]), ": IAC DO 1\n"),
00329             (tl.IAC + tl.DONT + bytes([1]), ": IAC DONT 1\n"),
00330             (tl.IAC + tl.WILL + bytes([1]), ": IAC WILL 1\n"),
00331             (tl.IAC + tl.WONT + bytes([1]), ": IAC WONT 1\n"),
00332            ]
00333         for a, b in given_a_expect_b:
00334             telnet = test_telnet([a])
00335             telnet.set_debuglevel(1)
00336             txt = telnet.read_all()
00337             self.assertIn(b, telnet._messages)
00338         return

Here is the call graph for this function:

Definition at line 339 of file test_telnetlib.py.

00339 
00340     def test_debuglevel_write(self):
00341         telnet = test_telnet()
00342         telnet.set_debuglevel(1)
00343         telnet.write(b'xxx')
00344         expected = "send b'xxx'\n"
00345         self.assertIn(expected, telnet._messages)

Here is the call graph for this function:

Definition at line 294 of file test_telnetlib.py.

00294 
00295     def test_IAC_commands(self):
00296         for cmd in self.cmds:
00297             self._test_command([tl.IAC, cmd])
00298             self._test_command([b'x' * 100, tl.IAC, cmd, b'y'*100])
00299             self._test_command([b'x' * 10, tl.IAC, cmd, b'y'*10])
00300         # all at once
00301         self._test_command([tl.IAC + cmd for (cmd) in self.cmds])

Here is the call graph for this function:

Definition at line 302 of file test_telnetlib.py.

00302 
00303     def test_SB_commands(self):
00304         # RFC 855, subnegotiations portion
00305         send = [tl.IAC + tl.SB + tl.IAC + tl.SE,
00306                 tl.IAC + tl.SB + tl.IAC + tl.IAC + tl.IAC + tl.SE,
00307                 tl.IAC + tl.SB + tl.IAC + tl.IAC + b'aa' + tl.IAC + tl.SE,
00308                 tl.IAC + tl.SB + b'bb' + tl.IAC + tl.IAC + tl.IAC + tl.SE,
00309                 tl.IAC + tl.SB + b'cc' + tl.IAC + tl.IAC + b'dd' + tl.IAC + tl.SE,
00310                ]
00311         telnet = test_telnet(send)
00312         nego = nego_collector(telnet.read_sb_data)
00313         telnet.set_option_negotiation_callback(nego.do_nego)
00314         txt = telnet.read_all()
00315         self.assertEqual(txt, b'')
00316         want_sb_data = tl.IAC + tl.IAC + b'aabb' + tl.IAC + b'cc' + tl.IAC + b'dd'
00317         self.assertEqual(nego.sb_seen, want_sb_data)
00318         self.assertEqual(b'', telnet.read_sb_data())
00319         nego.sb_getter = None # break the nego => telnet cycle

Here is the call graph for this function:


Member Data Documentation

list test.test_telnetlib.OptionTests.cmds = [tl.AO, tl.AYT, tl.BRK, tl.EC, tl.EL, tl.GA, tl.IP, tl.NOP] [static]

Definition at line 278 of file test_telnetlib.py.


The documentation for this class was generated from the following file: