| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import imp | 5 import imp |
| 6 import os.path | 6 import os.path |
| 7 import sys | 7 import sys |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 try: | 10 try: |
| 11 imp.find_module("devtoolslib") | 11 imp.find_module("devtoolslib") |
| 12 except ImportError: | 12 except ImportError: |
| 13 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 13 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 14 from devtoolslib import shell_arguments | 14 from devtoolslib import shell_arguments |
| 15 | 15 |
| 16 | 16 |
| 17 class AppendToArgumentTest(unittest.TestCase): | 17 class AppendToArgumentTest(unittest.TestCase): |
| 18 """Tests AppendToArgument().""" | 18 """Tests AppendToArgument().""" |
| 19 | 19 |
| 20 def testAppendToEmpty(self): | 20 def test_append_to_empty(self): |
| 21 arguments = [] | 21 arguments = [] |
| 22 key = '--something=' | 22 key = '--something=' |
| 23 value = 'val' | 23 value = 'val' |
| 24 expected_result = ['--something=val'] | 24 expected_result = ['--something=val'] |
| 25 self.assertEquals(expected_result, shell_arguments.append_to_argument( | 25 self.assertEquals(expected_result, shell_arguments.append_to_argument( |
| 26 arguments, key, value)) | 26 arguments, key, value)) |
| 27 | 27 |
| 28 def testAppendToNonEmpty(self): | 28 def test_append_to_non_empty(self): |
| 29 arguments = ['--other'] | 29 arguments = ['--other'] |
| 30 key = '--something=' | 30 key = '--something=' |
| 31 value = 'val' | 31 value = 'val' |
| 32 expected_result = ['--other', '--something=val'] | 32 expected_result = ['--other', '--something=val'] |
| 33 self.assertEquals(expected_result, shell_arguments.append_to_argument( | 33 self.assertEquals(expected_result, shell_arguments.append_to_argument( |
| 34 arguments, key, value)) | 34 arguments, key, value)) |
| 35 | 35 |
| 36 def testAppendToExisting(self): | 36 def test_append_to_existing(self): |
| 37 arguments = ['--something=old_val'] | 37 arguments = ['--something=old_val'] |
| 38 key = '--something=' | 38 key = '--something=' |
| 39 value = 'val' | 39 value = 'val' |
| 40 expected_result = ['--something=old_val,val'] | 40 expected_result = ['--something=old_val,val'] |
| 41 self.assertEquals(expected_result, shell_arguments.append_to_argument( | 41 self.assertEquals(expected_result, shell_arguments.append_to_argument( |
| 42 arguments, key, value)) | 42 arguments, key, value)) |
| 43 | 43 |
| 44 | 44 |
| 45 if __name__ == "__main__": | 45 if __name__ == "__main__": |
| 46 unittest.main() | 46 unittest.main() |
| OLD | NEW |