diff options
author | emerson.prado <emerson.prado@dataprev.gov.br> | 2019-03-05 14:13:58 -0300 |
---|---|---|
committer | emerson.prado <emerson.prado@dataprev.gov.br> | 2019-03-05 14:14:43 -0300 |
commit | e0cf843260dc7209905952b926d42fab35e80ff1 (patch) | |
tree | af8f033c31c84ad1ae8001d681ed6d9824c5a1bd | |
parent | f6d7ffa4760b50bcec29f7e8eeed8bd2d5fe88bb (diff) | |
download | pexpect-e0cf843260dc7209905952b926d42fab35e80ff1.tar.gz |
Add integration tests for regex coercing functions
-rwxr-xr-x | tests/test_expect.py | 24 |
1 files changed, 24 insertions, 0 deletions
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. |