pytty

changeset 20:0b78538ec01b

Added basic example of pytty.TTY usage with ptys
author Arc Riley <arcriley@gmail.com>
date Tue, 13 Dec 2011 16:18:20 -0500
parents 69b68fa5f779
children 39a1a84116a0
files src/__init__.py tests/TestDocs.py
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/src/__init__.py	Tue Dec 13 15:30:06 2011 -0500
     1.2 +++ b/src/__init__.py	Tue Dec 13 16:18:20 2011 -0500
     1.3 @@ -39,6 +39,16 @@
     1.4      which opens a tty device, sets nonblock mode on the device, and allows the
     1.5      user to change baud rate, flow control, and other settings often available
     1.6      to tty devices.
     1.7 +
     1.8 +        >>> import os
     1.9 +        >>> ptys = os.openpty()  # create two connected ptys for testing
    1.10 +        >>> master = pytty.TTY(ptys[0])
    1.11 +        >>> slave = pytty.TTY(ptys[1])
    1.12 +        >>> slave.write('Greetings, Master.')
    1.13 +        18L
    1.14 +        >>> slave.flush()
    1.15 +        >>> master.read()
    1.16 +        'Greetings, Master.'
    1.17      '''
    1.18  
    1.19      # This is intended to be overridden by some subclasses
     2.1 --- a/tests/TestDocs.py	Tue Dec 13 15:30:06 2011 -0500
     2.2 +++ b/tests/TestDocs.py	Tue Dec 13 16:18:20 2011 -0500
     2.3 @@ -35,7 +35,7 @@
     2.4      tests.addTests(doctest.DocTestSuite(
     2.5          module = pytty,
     2.6          globs = {
     2.7 -            'soy' : pytty,  # So examples don't need "import pytty"
     2.8 +            'pytty' : pytty,  # So examples don't need "import pytty"
     2.9          },
    2.10      ))
    2.11      return tests