MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / test

Function test

tools/python-3.11.9-amd64/Lib/telnetlib.py:651–676  ·  view source on GitHub ↗

Test program for telnetlib. Usage: python telnetlib.py [-d] ... [host [port]] Default host is localhost; default port is 23.

()

Source from the content-addressed store, hash-verified

649
650
651def test():
652 """Test program for telnetlib.
653
654 Usage: python telnetlib.py [-d] ... [host [port]]
655
656 Default host is localhost; default port is 23.
657
658 """
659 debuglevel = 0
660 while sys.argv[1:] and sys.argv[1] == '-d':
661 debuglevel = debuglevel+1
662 del sys.argv[1]
663 host = 'localhost'
664 if sys.argv[1:]:
665 host = sys.argv[1]
666 port = 0
667 if sys.argv[2:]:
668 portstr = sys.argv[2]
669 try:
670 port = int(portstr)
671 except ValueError:
672 port = socket.getservbyname(portstr, 'tcp')
673 with Telnet() as tn:
674 tn.set_debuglevel(debuglevel)
675 tn.open(host, port, timeout=0.5)
676 tn.interact()
677
678if __name__ == '__main__':
679 test()

Callers 1

telnetlib.pyFile · 0.70

Calls 4

TelnetClass · 0.85
set_debuglevelMethod · 0.45
openMethod · 0.45
interactMethod · 0.45

Tested by

no test coverage detected