diff options
author | Thomas Kluyver <takowl@gmail.com> | 2015-10-13 09:04:20 +0100 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2015-10-13 09:04:20 +0100 |
commit | 8a86932b770cd42ab1664b35a327b5f776b8c1df (patch) | |
tree | 3164fcec8a859884b62c87c1421bf58b0df822cb | |
parent | 75094b01cf2f3960faeaf0eadd0222ad73ebe4ce (diff) | |
parent | 209eec225dbdcb1c7f1a3ec889873dfd3ef09e82 (diff) | |
download | pexpect-git-8a86932b770cd42ab1664b35a327b5f776b8c1df.tar.gz |
Merge pull request #287 from pexpect/asyncio_utf8_issue
Asyncio utf8 issue
-rw-r--r-- | pexpect/async.py | 4 | ||||
-rw-r--r-- | tests/test_async.py | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/pexpect/async.py b/pexpect/async.py index ad75994..a798457 100644 --- a/pexpect/async.py +++ b/pexpect/async.py @@ -41,11 +41,11 @@ class PatternWaiter(asyncio.Protocol): spawn._log(s, 'read') if self.fut.done(): - spawn.buffer += data + spawn.buffer += s return try: - index = self.expecter.new_data(data) + index = self.expecter.new_data(s) if index is not None: # Found a match self.found(index) diff --git a/tests/test_async.py b/tests/test_async.py index ce75572..b918da6 100644 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -43,9 +43,15 @@ class AsyncTests(PexpectTestCase): coro = p.expect('Blah', async=True) with self.assertRaises(pexpect.EOF): run(coro) - + def test_expect_exact(self): p = pexpect.spawn('%s list100.py' % sys.executable) assert run(p.expect_exact(b'5', async=True)) == 0 assert run(p.expect_exact(['wpeok', b'11'], async=True)) == 1 assert run(p.expect_exact([b'foo', pexpect.EOF], async=True)) == 1 + + def test_async_utf8(self): + p = pexpect.spawn('%s list100.py' % sys.executable, encoding='utf8') + assert run(p.expect_exact(u'5', async=True)) == 0 + assert run(p.expect_exact([u'wpeok', u'11'], async=True)) == 1 + assert run(p.expect_exact([u'foo', pexpect.EOF], async=True)) == 1 |