本文整理汇总了Python中testing.testifycompat.assert_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_equal函数的具体用法?Python assert_equal怎么用?Python assert_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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()
示例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'))
示例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)
示例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
示例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)
示例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)
示例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')
示例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'))
示例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)
示例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')
示例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)
示例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)
示例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)
示例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)