diff options
author | pcarrier <pcarrier@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2010-11-27 22:12:49 +0000 |
---|---|---|
committer | pcarrier <pcarrier@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2010-11-27 22:12:49 +0000 |
commit | 754a0e45d79ae9252022edd5370bf3fd9f701e5f (patch) | |
tree | 6ac68017ce36f897e77b34ac477689cbd1912f5f /tests | |
parent | e234d20a8920e20f39a7ec6ceb58b039355a876b (diff) | |
download | sos-754a0e45d79ae9252022edd5370bf3fd9f701e5f.tar.gz |
[tests] worker: multiple helpers
Handling \r\n and \n is apparently more difficult than expected...
We want to make sure we do not let worker speak more than we expect
-> checking that .before is empty except when using lose_expect()
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@1040 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'tests')
-rw-r--r-- | tests/worker.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/worker.py b/tests/worker.py index 49d8bd15..38688fd7 100644 --- a/tests/worker.py +++ b/tests/worker.py @@ -14,17 +14,34 @@ class PexpectTest(unittest.TestCase): # worker should always be very fast to span self.expect('#0#\r\n') + def sig(self, sig): + kill(self.worker.pid, sig) + + def lose_expect(self, v, timeout = 3): + self.worker.expect(v, timeout) + + def expect(self, v, timeout = 3): + self.lose_expect(v, timeout) + self.assertEqual(self.worker.before, '') + + def send(self, text): + self.worker.send(text) + self.expect(escape(text)) + def sendlines(self, lines): for line in lines: - self.worker.sendline(line) - self.worker.expect(line+'\r\n') + self.worker.send(line+'\n') + for line in lines: + self.expect(escape(line)+'\r\n') - def expect(self, v, timeout = 3): - self.worker.expect(v, timeout) - self.assertEqual(self.worker.before, "") + def __finishes_ok__(self): + self.expect(pexpect.EOF) + self.worker.close() + self.assertEqual(self.worker.exitstatus, 0) def test_exit(self): self.sendlines(['exit']) + self.__finishes_ok__() self.expect(pexpect.EOF) def test_basic_noop(self): |