• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testifycompat.assert_equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中testing.testifycompat.assert_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_equal函数的具体用法?Python assert_equal怎么用?Python assert_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_equal函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_build_map_from_list_of_dicts

 def test_build_map_from_list_of_dicts(self):
     def map_by_id(d):
         return d['id'], d['value']
     map_validator = validation.build_map_type_validator(map_by_id)
     expected = {'a': 'b', 'c': 'd'}
     source = [dict(id='a', value='b'), dict(id='c', value='d')]
     assert_equal(map_validator(source), expected)
开发者ID:digideskio,项目名称:PyStaticConfiguration,代码行数:7,代码来源:validation_test.py


示例2: test_get_value_cached

 def test_get_value_cached(self):
     expected = "the other stars"
     validator = mock.Mock()
     value_proxy = proxy.ValueProxy(validator, self.value_cache, "something.string")
     value_proxy._value = expected
     assert_equal(value_proxy.value, expected)
     validator.assert_not_called()
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:7,代码来源:proxy_test.py


示例3: test_mock_configuration_context_manager

    def test_mock_configuration_context_manager(self):
        one = self.getters.get('one')
        three = self.getters.get_int('three', default=3)

        with testing.MockConfiguration(dict(one=7), namespace=self.namespace):
            assert_equal(one, 7)
            assert_equal(three, 3)
        assert_raises(errors.ConfigurationError, self.getters.get('one'))
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:8,代码来源:integration_test.py


示例4: test_build_reader

 def test_build_reader(self, mock_get_namespace):
     config_key, validator, self.namespace = 'the_key', mock.Mock(), 'the_name'
     reader = readers.build_reader(validator, self.namespace)
     value = reader(config_key)
     mock_get_namespace.assert_called_with(self.namespace)
     validator.assert_called_with(
         mock_get_namespace.return_value.get.return_value)
     assert_equal(value, validator.return_value)
开发者ID:digideskio,项目名称:PyStaticConfiguration,代码行数:8,代码来源:readers_test.py


示例5: test_proxy_zero

 def test_proxy_zero(self):
     validator = mock.Mock(return_value=0)
     self.value_proxy = proxy.ValueProxy(validator, self.value_cache, 'zero')
     assert_equal(self.value_proxy, 0)
     assert not self.value_proxy
     assert not self.value_proxy and True
     assert not self.value_proxy or False
     assert not self.value_proxy ^ 0
     assert ~ self.value_proxy
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:9,代码来源:proxy_test.py


示例6: test_build_getter

 def test_build_getter(self):
     validator = mock.Mock()
     getter = getters.build_getter(validator)
     assert callable(getter), "Getter is not callable"
     value_proxy = getter('the_name')
     namespace = config.get_namespace(config.DEFAULT)
     assert_in(id(value_proxy), namespace.value_proxies)
     assert_equal(value_proxy.config_key, "the_name")
     assert_equal(value_proxy.namespace, namespace)
开发者ID:digideskio,项目名称:PyStaticConfiguration,代码行数:9,代码来源:getters_test.py


示例7: test_build_getter_with_getter_namespace

 def test_build_getter_with_getter_namespace(self):
     validator = mock.Mock()
     name = 'the stars'
     getter = getters.build_getter(validator, getter_namespace=name)
     assert callable(getter), "Getter is not callable"
     value_proxy = getter('the_name')
     namespace = config.get_namespace(name)
     assert_in(id(value_proxy), namespace.value_proxies)
     assert_equal(value_proxy.config_key, "the_name")
     assert_equal(value_proxy.namespace, namespace)
开发者ID:digideskio,项目名称:PyStaticConfiguration,代码行数:10,代码来源:getters_test.py


示例8: test_init_nested

 def test_init_nested(self):
     conf = {
         'a': {
             'b': 'two',
         },
         'c': 'three'
     }
     with testing.MockConfiguration(conf):
         assert_equal(staticconf.get('a.b'), 'two')
         assert_equal(staticconf.get('c'), 'three')
开发者ID:digideskio,项目名称:PyStaticConfiguration,代码行数:10,代码来源:testing_test.py


示例9: test_mock_configuration

    def test_mock_configuration(self):
        two = self.getters.get_string('two')
        stars = self.getters.get_bool('stars')

        mock_config = testing.MockConfiguration(
            dict(two=2, stars=False), namespace=self.namespace)
        mock_config.setup()
        assert_equal(two, '2')
        assert not stars
        mock_config.teardown()
        assert_raises(errors.ConfigurationError, self.getters.get('two'))
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:11,代码来源:integration_test.py


示例10: test_proxy_with_datetime

 def test_proxy_with_datetime(self):
     the_date = datetime.datetime(2012, 12, 1, 5, 5, 5)
     validator = mock.Mock(return_value=the_date)
     value_proxy = proxy.ValueProxy(validator, self.value_cache, 'something')
     assert_equal(value_proxy, the_date)
     assert value_proxy < datetime.datetime(2012, 12, 3)
     assert value_proxy > datetime.datetime(2012, 1, 4)
     four_days_ahead = datetime.datetime(2012, 12, 4, 5, 5, 5)
     assert_equal(value_proxy + datetime.timedelta(days=3), four_days_ahead)
     assert_equal(repr(value_proxy), repr(the_date))
     assert_equal(str(value_proxy), str(the_date))
     assert_equal(hash(value_proxy), hash(the_date))
     assert bool(value_proxy)
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:13,代码来源:proxy_test.py


示例11: test_nested

    def test_nested(self):
        with testing.MockConfiguration(a='one', b='two'):
            with testing.PatchConfiguration(a='three'):
                assert_equal(staticconf.get('a'), 'three')
                assert_equal(staticconf.get('b'), 'two')

            assert_equal(staticconf.get('a'), 'one')
            assert_equal(staticconf.get('b'), 'two')
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:8,代码来源:testing_test.py


示例12: test_load_and_validate_namespace

 def test_load_and_validate_namespace(self):
     real_config = {'SomeClass.min': 20, 'SomeClass.max': 25}
     staticconf.DictConfiguration(self.config, namespace=SomeClass.namespace)
     staticconf.DictConfiguration(real_config, namespace=SomeClass.alt_name)
     some_class = SomeClass()
     assert_equal(some_class.max, 100)
     assert_equal(some_class.min, 0)
     assert_equal(some_class.real_min, 20)
     assert_equal(some_class.real_max, 25)
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:9,代码来源:integration_test.py


示例13: test_proxy_list

 def test_proxy_list(self):
     the_list = range(3)
     validator = mock.Mock(return_value=the_list)
     value_proxy = proxy.ValueProxy(validator, self.value_cache, 'the_list')
     assert_equal(value_proxy, the_list)
     assert_in(2, value_proxy)
     assert_equal(value_proxy[:1], range(0, 1))
     assert_equal(len(value_proxy), 3)
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:8,代码来源:proxy_test.py


示例14: test_build_value_type

 def test_build_value_type(self):
     help_text = 'what?'
     config_key = 'one'
     float_type = schema.build_value_type(validation.validate_float)
     assert callable(float_type)
     value_def = float_type(default=5, config_key=config_key, help=help_text)
     assert_equal(value_def.default, 5)
     assert_equal(value_def.help, help_text)
     assert_equal(value_def.config_key, config_key)
开发者ID:digideskio,项目名称:PyStaticConfiguration,代码行数:9,代码来源:schema_test.py


示例15: test_build_attributes

 def test_build_attributes(self, meta_schema):
     meta, _, mock_getters = meta_schema
     value_def = mock.create_autospec(schema.ValueTypeDefinition)
     attributes = {
         'not_a_token': None,
         'a_token': value_def
     }
     namespace = mock.create_autospec(config.ConfigNamespace)
     attributes = meta.build_attributes(attributes, namespace)
     assert_equal(attributes['not_a_token'], None)
     assert_equal(list(attributes['_tokens'].keys()), ['a_token'])
     token = attributes['_tokens']['a_token']
     assert_equal(token.config_key, value_def.config_key)
     assert_equal(token.default, value_def.default)
     assert isinstance(attributes['a_token'], property)
     mock_getters.register_value_proxy.assert_called_with(
         namespace, token, value_def.help)
开发者ID:digideskio,项目名称:PyStaticConfiguration,代码行数:17,代码来源:schema_test.py


示例16: test_reload_end_to_end

    def test_reload_end_to_end(self):
        loader = mock.Mock()
        facade = staticconf.ConfigFacade.load(
                self.file.name,
                self.namespace,
                loader)

        assert_equal(loader.call_count, 1)
        time.sleep(1)

        facade.reload_if_changed()
        assert_equal(loader.call_count, 1)
        os.utime(self.file.name, None)
        facade.reload_if_changed()
        assert_equal(loader.call_count, 2)
开发者ID:dnephin,项目名称:PyStaticConfiguration,代码行数:15,代码来源:config_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python udir.join函数代码示例发布时间:2022-05-27
下一篇:
Python subprocess.assert_command函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap