Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | |
michael@0 | 3 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | # You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 6 | |
michael@0 | 7 | import unittest |
michael@0 | 8 | from mozprocess import processhandler |
michael@0 | 9 | |
michael@0 | 10 | class ParamTests(unittest.TestCase): |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | def test_process_outputline_handler(self): |
michael@0 | 14 | """Parameter processOutputLine is accepted with a single function""" |
michael@0 | 15 | def output(line): |
michael@0 | 16 | print("output " + str(line)) |
michael@0 | 17 | err = None |
michael@0 | 18 | try: |
michael@0 | 19 | p = processhandler.ProcessHandler(['ls','-l'], processOutputLine=output) |
michael@0 | 20 | except (TypeError, AttributeError) as e: |
michael@0 | 21 | err = e |
michael@0 | 22 | self.assertFalse(err) |
michael@0 | 23 | |
michael@0 | 24 | def test_process_outputline_handler_list(self): |
michael@0 | 25 | """Parameter processOutputLine is accepted with a list of functions""" |
michael@0 | 26 | def output(line): |
michael@0 | 27 | print("output " + str(line)) |
michael@0 | 28 | err = None |
michael@0 | 29 | try: |
michael@0 | 30 | p = processhandler.ProcessHandler(['ls','-l'], processOutputLine=[output]) |
michael@0 | 31 | except (TypeError, AttributeError) as e: |
michael@0 | 32 | err = e |
michael@0 | 33 | self.assertFalse(err) |
michael@0 | 34 | |
michael@0 | 35 | |
michael@0 | 36 | def test_process_ontimeout_handler(self): |
michael@0 | 37 | """Parameter onTimeout is accepted with a single function""" |
michael@0 | 38 | def timeout(): |
michael@0 | 39 | print("timeout!") |
michael@0 | 40 | err = None |
michael@0 | 41 | try: |
michael@0 | 42 | p = processhandler.ProcessHandler(['sleep', '2'], onTimeout=timeout) |
michael@0 | 43 | except (TypeError, AttributeError) as e: |
michael@0 | 44 | err = e |
michael@0 | 45 | self.assertFalse(err) |
michael@0 | 46 | |
michael@0 | 47 | def test_process_ontimeout_handler_list(self): |
michael@0 | 48 | """Parameter onTimeout is accepted with a list of functions""" |
michael@0 | 49 | def timeout(): |
michael@0 | 50 | print("timeout!") |
michael@0 | 51 | err = None |
michael@0 | 52 | try: |
michael@0 | 53 | p = processhandler.ProcessHandler(['sleep', '2'], onTimeout=[timeout]) |
michael@0 | 54 | except (TypeError, AttributeError) as e: |
michael@0 | 55 | err = e |
michael@0 | 56 | self.assertFalse(err) |
michael@0 | 57 | |
michael@0 | 58 | def test_process_onfinish_handler(self): |
michael@0 | 59 | """Parameter onFinish is accepted with a single function""" |
michael@0 | 60 | def finish(): |
michael@0 | 61 | print("finished!") |
michael@0 | 62 | err = None |
michael@0 | 63 | try: |
michael@0 | 64 | p = processhandler.ProcessHandler(['sleep', '1'], onFinish=finish) |
michael@0 | 65 | except (TypeError, AttributeError) as e: |
michael@0 | 66 | err = e |
michael@0 | 67 | self.assertFalse(err) |
michael@0 | 68 | |
michael@0 | 69 | def test_process_onfinish_handler_list(self): |
michael@0 | 70 | """Parameter onFinish is accepted with a list of functions""" |
michael@0 | 71 | def finish(): |
michael@0 | 72 | print("finished!") |
michael@0 | 73 | err = None |
michael@0 | 74 | try: |
michael@0 | 75 | p = processhandler.ProcessHandler(['sleep', '1'], onFinish=[finish]) |
michael@0 | 76 | except (TypeError, AttributeError) as e: |
michael@0 | 77 | err = e |
michael@0 | 78 | self.assertFalse(err) |
michael@0 | 79 | |
michael@0 | 80 | |
michael@0 | 81 | def main(): |
michael@0 | 82 | unittest.main() |
michael@0 | 83 | |
michael@0 | 84 | if __name__ == '__main__': |
michael@0 | 85 | main() |
michael@0 | 86 |