"Fossies" - the Fresh Open Source Software Archive

Member "reptyr-reptyr-0.8.0/test/basic.py" (29 Sep 2020, 666 Bytes) of package /linux/privat/reptyr-reptyr-0.8.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "basic.py": 0.7.0_vs_0.8.0.

    1 import os
    2 import pexpect
    3 import sys
    4 
    5 from util import expect_eof
    6 
    7 if os.getenv("NO_TEST_BASIC") is not None:
    8     print("Skipping basic tests because $NO_TEST_BASIC is set.")
    9     sys.exit(0)
   10 
   11 logfile = sys.stdout
   12 if sys.version_info[0] >= 3:
   13     logfile = logfile.buffer
   14 
   15 child = pexpect.spawn("test/victim")
   16 child.logfile = logfile
   17 child.setecho(False)
   18 child.sendline("hello")
   19 child.expect("ECHO: hello")
   20 
   21 reptyr = pexpect.spawn("./reptyr -V %d" % (child.pid,))
   22 reptyr.logfile = logfile
   23 reptyr.sendline("world")
   24 reptyr.expect("ECHO: world")
   25 
   26 child.sendline("final")
   27 expect_eof(child.child_fd)
   28 
   29 reptyr.sendeof()
   30 reptyr.expect(pexpect.EOF)
   31 assert not reptyr.isalive()