Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/typ/typ/tests/arg_parser_test.py

Issue 2568683002: Roll //third_party/typ to v0.9.9 (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/typ/typ/arg_parser.py ('k') | third_party/typ/typ/version.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « third_party/typ/typ/arg_parser.py ('k') | third_party/typ/typ/version.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698