summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozprocess/tests/test_mozprocess_output.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/mozbase/mozprocess/tests/test_mozprocess_output.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/mozbase/mozprocess/tests/test_mozprocess_output.py')
-rw-r--r--testing/mozbase/mozprocess/tests/test_mozprocess_output.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/testing/mozbase/mozprocess/tests/test_mozprocess_output.py b/testing/mozbase/mozprocess/tests/test_mozprocess_output.py
new file mode 100644
index 000000000..e9ad26620
--- /dev/null
+++ b/testing/mozbase/mozprocess/tests/test_mozprocess_output.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+
+import io
+import os
+import unittest
+import proctest
+from mozprocess import processhandler
+
+here = os.path.dirname(os.path.abspath(__file__))
+
+
+class ProcTestOutput(proctest.ProcTest):
+ """ Class to test operations related to output handling """
+
+ def test_process_output_nonewline(self):
+ """
+ Process is started, outputs data with no newline
+ """
+ p = processhandler.ProcessHandler([self.python, "procnonewline.py"],
+ cwd=here)
+
+ p.run()
+ p.processOutput(timeout=5)
+ p.wait()
+
+ self.determine_status(p, False, ())
+
+ def test_stream_process_output(self):
+ """
+ Process output stream does not buffer
+ """
+ expected = '\n'.join([str(n) for n in range(0, 10)])
+
+ stream = io.BytesIO()
+ buf = io.BufferedRandom(stream)
+
+ p = processhandler.ProcessHandler([self.python, "proccountfive.py"],
+ cwd=here,
+ stream=buf)
+
+ p.run()
+ p.wait()
+ for i in range(5, 10):
+ stream.write(str(i) + '\n')
+
+ buf.flush()
+ self.assertEquals(stream.getvalue().strip(), expected)
+
+ # make sure mozprocess doesn't close the stream
+ # since mozprocess didn't create it
+ self.assertFalse(buf.closed)
+ buf.close()
+
+ self.determine_status(p, False, ())
+
+if __name__ == '__main__':
+ unittest.main()