当前位置: 首页>>代码示例>>Python>>正文


Python Context.get_value方法代码示例

本文整理汇总了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'))
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:10,代码来源:test_tests.py

示例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'))
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:15,代码来源:test_tests.py

示例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)
开发者ID:LGordon2,项目名称:pyresttest,代码行数:17,代码来源:test_binding.py

示例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)
开发者ID:LGordon2,项目名称:pyresttest,代码行数:11,代码来源:test_binding.py

示例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())
开发者ID:LGordon2,项目名称:pyresttest,代码行数:14,代码来源:test_binding.py

示例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())
开发者ID:LGordon2,项目名称:pyresttest,代码行数:18,代码来源:test_tests.py

示例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())
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:20,代码来源:functionaltest.py


注:本文中的binding.Context.get_value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。