From e0cf843260dc7209905952b926d42fab35e80ff1 Mon Sep 17 00:00:00 2001 From: "emerson.prado" Date: Tue, 5 Mar 2019 14:13:58 -0300 Subject: Add integration tests for regex coercing functions --- tests/test_expect.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_expect.py b/tests/test_expect.py index 4726b94..31a4592 100755 --- a/tests/test_expect.py +++ b/tests/test_expect.py @@ -151,6 +151,30 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase): self.assertIsInstance(c.pattern, expected_type) p.expect (pexpect.EOF) + def test_expect_regex_enc_none (self): + '''This test that bytes mode spawn objects (encoding=None) + parses correctly regex patterns compiled from non-bytes type objects + ''' + p = pexpect.spawn('cat', echo=False, timeout=5) + p.sendline ('We are the Knights who say "Ni!"') + index = p.expect ([re.compile('We are the Knights who say "Ni!"'), + pexpect.EOF, pexpect.TIMEOUT]) + self.assertEqual(index, 0) + p.sendeof () + p.expect_exact (pexpect.EOF) + + def test_expect_regex_enc_utf8 (self): + '''This test that non-bytes mode spawn objects (encoding='utf-8') + parses correctly regex patterns compiled from bytes type objects + ''' + p = pexpect.spawn('cat', echo=False, timeout=5, encoding='utf-8') + p.sendline ('We are the Knights who say "Ni!"') + index = p.expect ([re.compile(b'We are the Knights who say "Ni!"'), + pexpect.EOF, pexpect.TIMEOUT]) + self.assertEqual(index, 0) + p.sendeof () + p.expect_exact (pexpect.EOF) + def test_expect_order (self): '''This tests that patterns are matched in the same order as given in the pattern_list. -- cgit v1.2.1