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

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

Issue 2856003002: [doc] fix doc to work in all known repos. (Closed)
Patch Set: fix other test Created 3 years, 7 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
« recipe_engine/recipe_api.py ('K') | « recipe_engine/recipe_api.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 LUCI Authors. All rights reserved. 2 # Copyright 2015 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import unittest 6 import unittest
7 7
8 import test_env 8 import test_env
9 9
10 from recipe_engine import recipe_api, config 10 from recipe_engine import recipe_api, config
11 11
12 def make_prop(**kwargs): 12 def make_prop(**kwargs):
13 name = kwargs.pop('name', "dumb_name") 13 name = kwargs.pop('name', "dumb_name")
14 return recipe_api.Property(**kwargs).bind(name, 'test', 'properties_test') 14 return recipe_api.Property(**kwargs).bind(name, 'test', 'properties_test')
15 15
16 class TestProperties(unittest.TestCase): 16 class TestProperties(unittest.TestCase):
17 def testDefault(self): 17 def testDefault(self):
18 """Tests the default option of properties.""" 18 """Tests the default option of properties."""
19 for default in (1, object(), "test", None): 19 for default in (1, {}, "test", None):
20 prop = make_prop(default=default) 20 prop = make_prop(default=default)
21 self.assertEqual(default, prop.interpret(recipe_api.PROPERTY_SENTINEL)) 21 self.assertEqual(default, prop.interpret(recipe_api.PROPERTY_SENTINEL))
22 22
23 def testRequired(self): 23 def testRequired(self):
24 """Tests that a required property errors when not provided.""" 24 """Tests that a required property errors when not provided."""
25 prop = make_prop() 25 prop = make_prop()
26 with self.assertRaises(ValueError): 26 with self.assertRaises(ValueError):
27 prop.interpret(recipe_api.PROPERTY_SENTINEL) 27 prop.interpret(recipe_api.PROPERTY_SENTINEL)
28 28
29 def testTypeSingle(self): 29 def testTypeSingle(self):
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 Tests setting a param name correctly carries through to a bound property. 79 Tests setting a param name correctly carries through to a bound property.
80 """ 80 """
81 prop = recipe_api.Property(param_name='good_name') 81 prop = recipe_api.Property(param_name='good_name')
82 bound = prop.bind('bad.name-time', 'test', 'test_me') 82 bound = prop.bind('bad.name-time', 'test', 'test_me')
83 83
84 self.assertEqual('good_name', bound.param_name) 84 self.assertEqual('good_name', bound.param_name)
85 85
86 86
87 if __name__ == '__main__': 87 if __name__ == '__main__':
88 unittest.main() 88 unittest.main()
OLDNEW
« recipe_engine/recipe_api.py ('K') | « recipe_engine/recipe_api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698