OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (C) 2013 Google Inc. All rights reserved. | 2 # Copyright (C) 2013 Google Inc. All rights reserved. |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 24 matching lines...) Expand all Loading... | |
35 def test_basic_parse(self): | 35 def test_basic_parse(self): |
36 contents = """ | 36 contents = """ |
37 name1 arg=value, arg2=value2, arg2=value3 | 37 name1 arg=value, arg2=value2, arg2=value3 |
38 name2 | 38 name2 |
39 """ | 39 """ |
40 lines = contents.split("\n") | 40 lines = contents.split("\n") |
41 defaults = { | 41 defaults = { |
42 'arg': None, | 42 'arg': None, |
43 'arg2': [], | 43 'arg2': [], |
44 } | 44 } |
45 in_file = InFile(lines, defaults) | 45 in_file = InFile(lines, defaults, None) |
46 expected_values = [ | 46 expected_values = [ |
47 {'name': 'name1', 'arg': 'value', 'arg2': ['value2', 'value3']}, | 47 {'name': 'name1', 'arg': 'value', 'arg2': ['value2', 'value3']}, |
48 {'name': 'name2', 'arg': None, 'arg2': []}, | 48 {'name': 'name2', 'arg': None, 'arg2': []}, |
49 ] | 49 ] |
50 self.assertEquals(in_file.name_dictionaries, expected_values) | 50 self.assertEquals(in_file.name_dictionaries, expected_values) |
51 | 51 |
52 def test_with_parameters(self): | |
53 contents = """namespace=TestNamespace | |
eseidel
2013/04/30 21:46:16
Yes, requiring no leading newline is making your t
abarth-chromium
2013/04/30 21:50:44
Actually, it looks like the Perl support leading b
| |
54 fruit | |
55 | |
56 name1 arg=value, arg2=value2, arg2=value3 | |
57 name2 | |
58 """ | |
59 lines = contents.split("\n") | |
60 defaults = { | |
61 'arg': None, | |
62 'arg2': [], | |
63 } | |
64 default_parameters = { | |
65 'namespace': '', | |
66 'fruit': False, | |
67 } | |
68 in_file = InFile(lines, defaults, default_parameters) | |
69 expected_parameters = { | |
70 'namespace': 'TestNamespace', | |
71 'fruit': True, | |
72 } | |
73 self.assertEquals(in_file.parameters, expected_parameters) | |
74 | |
75 | |
52 if __name__ == "__main__": | 76 if __name__ == "__main__": |
53 unittest.main() | 77 unittest.main() |
OLD | NEW |