| OLD | NEW |
| 1 # Copyright 2014 Dirk Pranke. All rights reserved. | 1 # Copyright 2014 Dirk Pranke. All rights reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 args = parser.parse_args(argv) | 37 args = parser.parse_args(argv) |
| 38 actual_argv = parser.argv_from_args(args) | 38 actual_argv = parser.argv_from_args(args) |
| 39 expected = expected or argv | 39 expected = expected or argv |
| 40 self.assertEqual(expected, actual_argv) | 40 self.assertEqual(expected, actual_argv) |
| 41 | 41 |
| 42 check(['--version']) | 42 check(['--version']) |
| 43 check(['--coverage', '--coverage-omit', 'foo']) | 43 check(['--coverage', '--coverage-omit', 'foo']) |
| 44 check(['--jobs', '3']) | 44 check(['--jobs', '3']) |
| 45 check(['-vv'], ['--verbose', '--verbose']) | 45 check(['-vv'], ['--verbose', '--verbose']) |
| 46 | 46 |
| 47 def test_argv_from_args_foreign_argument(self): |
| 48 parser = ArgumentParser() |
| 49 parser.add_argument('--some-foreign-argument', default=False, |
| 50 action='store_true') |
| 51 args = parser.parse_args(['--some-foreign-argument', '--verbose']) |
| 52 self.assertEqual(['--verbose'], ArgumentParser().argv_from_args(args)) |
| 53 |
| 47 def test_valid_shard_options(self): | 54 def test_valid_shard_options(self): |
| 48 parser = ArgumentParser() | 55 parser = ArgumentParser() |
| 49 | 56 |
| 50 parser.parse_args(['--total-shards', '1']) | 57 parser.parse_args(['--total-shards', '1']) |
| 51 self.assertEqual(parser.exit_status, None) | 58 self.assertEqual(parser.exit_status, None) |
| 52 | 59 |
| 53 parser.parse_args(['--total-shards', '5', '--shard-index', '4']) | 60 parser.parse_args(['--total-shards', '5', '--shard-index', '4']) |
| 54 self.assertEqual(parser.exit_status, None) | 61 self.assertEqual(parser.exit_status, None) |
| 55 | 62 |
| 56 parser.parse_args(['--total-shards', '5', '--shard-index', '0']) | 63 parser.parse_args(['--total-shards', '5', '--shard-index', '0']) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 67 self.assertEqual(parser.exit_status, 2) | 74 self.assertEqual(parser.exit_status, 2) |
| 68 | 75 |
| 69 parser.parse_args(['--total-shards', '5', '--shard-index', '-1']) | 76 parser.parse_args(['--total-shards', '5', '--shard-index', '-1']) |
| 70 self.assertEqual(parser.exit_status, 2) | 77 self.assertEqual(parser.exit_status, 2) |
| 71 | 78 |
| 72 parser.parse_args(['--total-shards', '5', '--shard-index', '5']) | 79 parser.parse_args(['--total-shards', '5', '--shard-index', '5']) |
| 73 self.assertEqual(parser.exit_status, 2) | 80 self.assertEqual(parser.exit_status, 2) |
| 74 | 81 |
| 75 parser.parse_args(['--total-shards', '5', '--shard-index', '6']) | 82 parser.parse_args(['--total-shards', '5', '--shard-index', '6']) |
| 76 self.assertEqual(parser.exit_status, 2) | 83 self.assertEqual(parser.exit_status, 2) |
| OLD | NEW |