<commit_before>""" 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.closed = False
        try:
            child.expect('alpha', timeout=0.1)
        except pexpect.TIMEOUT:
            pass
        else:
            assert False, 'TIMEOUT exception expected. No exception aised.'<commit_msg>bugfix test for conditional str() coverage<commit_after>""" 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:
            pass
        else:
            assert False, 'TIMEOUT exception expected. No exception aised.'
{'fraction_non_alphanumeric': 0.11360239162929746, 'fraction_numerical': 0.001993024414549078, 'mean_word_length': 2.0750382848392035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '873984', 'n_tokens_mistral': 585, 'n_tokens_neox': 582, 'n_words': 137}