File: test_delay.py

package info (click to toggle)
pexpect 4.9-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,184 kB
  • sloc: python: 10,774; makefile: 138; sh: 73; ansic: 69
file content (45 lines) | stat: -rw-r--r-- 994 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-

from . import PexpectTestCase
import pexpect


class TestCaseDelay(PexpectTestCase.PexpectTestCase):
    """
    Tests for various delay attributes.
    """
    def test_delaybeforesend(self):
        """
        Test various values for delaybeforesend.
        """
        p = pexpect.spawn("cat")

        p.delaybeforesend = 1
        p.sendline("line 1")
        p.expect("line 1")

        p.delaybeforesend = 0.0
        p.sendline("line 2")
        p.expect("line 2")

        p.delaybeforesend = None
        p.sendline("line 3")
        p.expect("line 3")

    def test_delayafterread(self):
        """
        Test various values for delayafterread.
        """
        p = pexpect.spawn("cat")

        p.delayafterread = 1
        p.sendline("line 1")
        p.expect("line 1")

        p.delayafterread = 0.0
        p.sendline("line 2")
        p.expect("line 2")

        p.delayafterread = None
        p.sendline("line 3")
        p.expect("line 3")