本文整理汇总了Python中binding.Context.get_value方法的典型用法代码示例。如果您正苦于以下问题:Python Context.get_value方法的具体用法?Python Context.get_value怎么用?Python Context.get_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类binding.Context
的用法示例。
在下文中一共展示了Context.get_value方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_context_variables
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import get_value [as 别名]
def test_update_context_variables(self):
test = Test()
context = Context()
context.bind_variable('foo', 'broken')
test.variable_binds = {'foo': 'correct', 'test': 'value'}
test.update_context_before(context)
self.assertEqual('correct', context.get_value('foo'))
self.assertEqual('value', context.get_value('test'))
示例2: test_update_context_generators
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import get_value [as 别名]
def test_update_context_generators(self):
""" Test updating context variables using generator """
test = Test()
context = Context()
context.bind_variable('foo', 'broken')
test.variable_binds = {'foo': 'initial_value'}
test.generator_binds = {'foo': 'gen'}
context.add_generator('gen', generators.generator_basic_ids())
test.update_context_before(context)
self.assertEqual(1, context.get_value('foo'))
test.update_context_before(context)
self.assertEqual(2, context.get_value('foo'))
示例3: test_variables
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import get_value [as 别名]
def test_variables(self):
""" Test bind/return of variables """
context = Context()
self.assertTrue(context.get_value('foo') is None)
self.assertEqual(0, context.mod_count)
context.bind_variable('foo','bar')
self.assertEqual('bar', context.get_value('foo'))
self.assertEqual('bar', context.get_values()['foo'])
self.assertEqual(1, context.mod_count)
context.bind_variable('foo','bar2')
self.assertEqual('bar2', context.get_value('foo'))
self.assertEqual(2, context.mod_count)
示例4: test_mixing_binds
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import get_value [as 别名]
def test_mixing_binds(self):
""" Ensure that variables are set correctly when mixing explicit declaration and variables """
context = Context()
context.add_generator('gen', count_gen())
context.bind_variable('foo', '100')
self.assertEqual(1, context.mod_count)
context.bind_generator_next('foo', 'gen')
self.assertEqual(1, context.get_value('foo'))
self.assertEqual(2, context.mod_count)
示例5: test_generator_bind
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import get_value [as 别名]
def test_generator_bind(self):
""" Test generator setting to variables """
context = Context()
self.assertEqual(0, len(context.get_generators()))
my_gen = count_gen()
context.add_generator('gen', my_gen)
context.bind_generator_next('foo', 'gen')
self.assertEqual(1, context.mod_count)
self.assertEqual(1, context.get_value('foo'))
self.assertTrue(2, context.get_generator('gen').next())
self.assertTrue(3, my_gen.next())
示例6: test_variable_binding
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import get_value [as 别名]
def test_variable_binding(self):
""" Test that tests successfully bind variables """
element = 3
input = [{"url": "/ping"},{"name": "cheese"},{"expected_status":["200",204,"202"]}]
input.append({"variable_binds":{'var':'value'}})
test = Test.parse_test('', input)
binds = test.variable_binds
self.assertEqual(1, len(binds))
self.assertEqual('value', binds['var'])
# Test that updates context correctly
context = Context()
test.update_context_before(context)
self.assertEqual('value', context.get_value('var'))
self.assertTrue(test.is_context_modifier())
示例7: test_header_extraction
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import get_value [as 别名]
def test_header_extraction(self):
test = Test()
test.url = self.prefix + "/api/person/1/"
key1 = "server-header"
key2 = "server-header-mixedcase"
test.extract_binds = {
key1: validators.HeaderExtractor.parse("server"),
# Verify case-insensitive behavior
key2: validators.HeaderExtractor.parse("sErVer"),
}
my_context = Context()
test_response = resttest.run_test(test, context=my_context)
val1 = my_context.get_value(key1)
val2 = my_context.get_value(key2)
self.assertEqual(val1, val2)
self.assertTrue("wsgi" in val1.lower())
self.assertTrue("wsgi" in val2.lower())