OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 ''' |
| 3 PEXPECT LICENSE |
| 4 |
| 5 This license is approved by the OSI and FSF as GPL-compatible. |
| 6 http://opensource.org/licenses/isc-license.txt |
| 7 |
| 8 Copyright (c) 2012, Noah Spurrier <noah@noah.org> |
| 9 PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY |
| 10 PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE |
| 11 COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. |
| 12 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 13 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 14 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 15 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 |
| 20 ''' |
| 21 import pexpect |
| 22 import unittest |
| 23 import re |
| 24 from . import PexpectTestCase |
| 25 |
| 26 testdata = 'BEGIN\nHello world\nEND' |
| 27 class TestCaseDotall(PexpectTestCase.PexpectTestCase): |
| 28 def test_dotall (self): |
| 29 p = pexpect.spawn('echo "%s"' % testdata) |
| 30 i = p.expect ([b'BEGIN(.*)END', pexpect.EOF]) |
| 31 assert i==0, 'DOTALL does not seem to be working.' |
| 32 |
| 33 def test_precompiled (self): |
| 34 p = pexpect.spawn('echo "%s"' % testdata) |
| 35 pat = re.compile(b'BEGIN(.*)END') # This overrides the default DOTALL. |
| 36 i = p.expect ([pat, pexpect.EOF]) |
| 37 assert i==1, 'Precompiled pattern to override DOTALL does not seem to be
working.' |
| 38 |
| 39 if __name__ == '__main__': |
| 40 unittest.main() |
| 41 |
| 42 suite = unittest.makeSuite(TestCaseDotall,'test') |
| 43 |
OLD | NEW |