summaryrefslogtreecommitdiff
path: root/tests/test_repr.py
blob: ac337160d7e78980c925c52a765cbd9872db98f9 (plain)
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
""" Test __str__ methods. """
import pexpect

from . import PexpectTestCase


class TestCaseMisc(PexpectTestCase.PexpectTestCase):

    def test_str_spawnu(self):
        """ Exercise spawnu.__str__() """
        # given,
        p = pexpect.spawnu('cat')
        # exercise,
        value = str(p)
        # verify
        assert isinstance(value, str)

    def test_str_spawn(self):
        """ Exercise spawn.__str__() """
        # given,
        p = pexpect.spawn('cat')
        # exercise,
        value = str(p)
        # verify
        assert isinstance(value, str)

    def test_str_before_spawn(self):
        """ Exercise derived spawn.__str__() """
        # given,
        child = pexpect.spawn(None, None)
        child.read_nonblocking = lambda size, timeout: b''
        try:
            child.expect('alpha', timeout=0.1)
        except pexpect.TIMEOUT as e:
            str(e)  # Smoketest
        else:
            assert False, 'TIMEOUT exception expected. No exception raised.'