| OLD | NEW |
| 1 # | 1 # |
| 2 # Copyright 2008 Google Inc. All Rights Reserved. | 2 # Copyright 2008 Google Inc. All Rights Reserved. |
| 3 | 3 |
| 4 """Test for cli.""" | 4 """Test for cli.""" |
| 5 | 5 |
| 6 import unittest, os, sys, StringIO | 6 import unittest, os, sys, StringIO |
| 7 | 7 |
| 8 import common | 8 import common |
| 9 from autotest_lib.cli import atest, topic_common, rpc | 9 from autotest_lib.cli import atest, topic_common, rpc |
| 10 from autotest_lib.frontend.afe import rpc_client_lib | 10 from autotest_lib.frontend.afe import rpc_client_lib |
| 11 from autotest_lib.frontend.afe.json_rpc import proxy | 11 from autotest_lib.frontend.afe.json_rpc import proxy |
| 12 from autotest_lib.client.common_lib.test_utils import mock | 12 from autotest_lib.client.common_lib.test_utils import mock |
| 13 from autotest_lib.client.common_lib import autotemp | 13 from autotest_lib.client.common_lib import autotemp |
| 14 | 14 |
| 15 CLI_USING_PDB = False | 15 CLI_USING_PDB = False |
| 16 CLI_UT_DEBUG = False | 16 CLI_UT_DEBUG = False |
| 17 | 17 |
| 18 def create_file(content): | 18 def create_file(content): |
| 19 file_temp = autotemp.tempfile(unique_id='cli_mock', text=True) | 19 file_temp = autotemp.tempfile(unique_id='cli_mock', text=True) |
| 20 os.write(file_temp.fd, content) | 20 os.write(file_temp.fd, content) |
| 21 os.close(file_temp.fd) | |
| 22 return file_temp | 21 return file_temp |
| 23 | 22 |
| 24 | 23 |
| 25 class ExitException(Exception): | 24 class ExitException(Exception): |
| 26 pass | 25 pass |
| 27 | 26 |
| 28 | 27 |
| 29 class cli_unittest(unittest.TestCase): | 28 class cli_unittest(unittest.TestCase): |
| 30 def setUp(self): | 29 def setUp(self): |
| 31 super(cli_unittest, self).setUp() | 30 super(cli_unittest, self).setUp() |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if exit_code is not None: | 111 if exit_code is not None: |
| 113 sys.exit.expect_call(exit_code).and_raises(ExitException) | 112 sys.exit.expect_call(exit_code).and_raises(ExitException) |
| 114 self.assertRaises(ExitException, atest.main) | 113 self.assertRaises(ExitException, atest.main) |
| 115 else: | 114 else: |
| 116 atest.main() | 115 atest.main() |
| 117 (out, err) = self.god.unmock_io() | 116 (out, err) = self.god.unmock_io() |
| 118 self.god.check_playback() | 117 self.god.check_playback() |
| 119 self._check_output(out, out_words_ok, out_words_no, | 118 self._check_output(out, out_words_ok, out_words_no, |
| 120 err, err_words_ok, err_words_no) | 119 err, err_words_ok, err_words_no) |
| 121 return (out, err) | 120 return (out, err) |
| OLD | NEW |