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

Side by Side Diff: recipe_engine/unittests/loader_test.py

Issue 1755593003: Fix param_name for Properties. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Created 4 years, 9 months 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 | « recipe_engine/loader.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 import sys 7 import sys
8 import unittest 8 import unittest
9 9
10 BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname( 10 BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 'b': make_prop(name="b"), 71 'b': make_prop(name="b"),
72 } 72 }
73 73
74 props = { 74 props = {
75 'a': 1, 75 'a': 1,
76 'b': 2, 76 'b': 2,
77 } 77 }
78 self.assertEqual(1, self.invoke(func, props, prop_defs, ['a', 'b'])) 78 self.assertEqual(1, self.invoke(func, props, prop_defs, ['a', 'b']))
79 79
80 def testInvokeParamName(self): 80 def testInvokeParamName(self):
81 """Tests invoke with two different properties.""" 81 """Tests invoke with a param name."""
82 def func(a): 82 def func(c):
83 return a 83 return c
84 84
85 prop_defs = { 85 prop_defs = {
86 'a': make_prop(name='b'), 86 'b.a': make_prop(name="c", param_name="c"),
87 } 87 }
88 88
89 props = { 89 props = {
90 'b': 2, 90 'b.a': 2,
91 } 91 }
92 self.assertEqual(2, self.invoke(func, props, prop_defs, ['a'])) 92 self.assertEqual(2, self.invoke(func, props, prop_defs, ['c']))
93 93
94 def testInvokeClass(self): 94 def testInvokeClass(self):
95 """Tests invoking a class.""" 95 """Tests invoking a class."""
96 class test(object): 96 class test(object):
97 def __init__(self, a, b): # pylint: disable=unused-argument 97 def __init__(self, a, b): # pylint: disable=unused-argument
98 self.answer = a 98 self.answer = a
99 99
100 prop_defs = { 100 prop_defs = {
101 'a': make_prop(name="a"), 101 'a': make_prop(name="a"),
102 'b': make_prop(name="b"), 102 'b': make_prop(name="b"),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 with mock.patch( 143 with mock.patch(
144 'recipe_engine.loader._invoke_with_properties') as mocked_invoke: 144 'recipe_engine.loader._invoke_with_properties') as mocked_invoke:
145 loader.invoke_with_properties(TestClass, None, None) 145 loader.invoke_with_properties(TestClass, None, None)
146 args, _ = mocked_invoke.call_args 146 args, _ = mocked_invoke.call_args
147 self.assertTrue(['api', 'foo', 'bar'] in args) 147 self.assertTrue(['api', 'foo', 'bar'] in args)
148 148
149 149
150 if __name__ == '__main__': 150 if __name__ == '__main__':
151 unittest.main() 151 unittest.main()
OLDNEW
« no previous file with comments | « recipe_engine/loader.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698