本文整理汇总了Python中nose.tools.assert_equal方法的典型用法代码示例。如果您正苦于以下问题:Python tools.assert_equal方法的具体用法?Python tools.assert_equal怎么用?Python tools.assert_equal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.tools
的用法示例。
在下文中一共展示了tools.assert_equal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_dicter
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_custom_dicter():
# Allow custom dict-like object in constructor
class MyDict(object):
def __init__(self):
self._keys = []
def __setitem__(self, key, value):
self._keys.append(key)
def __getitem__(self, key):
if key in self._keys:
return 'spam'
return 'eggs'
def keys(self):
return ['some', 'keys']
def values(self):
return ['funny', 'list']
# code, label, aliases
codes = ((1,'one','1','first'), (2,'two'))
rc = Recoder(codes, map_maker=MyDict)
yield assert_equal, rc.code[1], 'spam'
yield assert_equal, rc.code['one'], 'spam'
yield assert_equal, rc.code['first'], 'spam'
yield assert_equal, rc.code['bizarre'], 'eggs'
yield assert_equal, rc.value_set(), set(['funny', 'list'])
yield assert_equal, list(rc.keys()), ['some', 'keys']
示例2: test_comparison_keys
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_comparison_keys(self):
c_list = [
['class', 'ABD'],
['enum', 'ABDa'],
['class', 'abcd'],
]
ref_sort_idx = [0, 2, 1]
c_obj_list = []
for c_type, c_name in c_list:
c_obj_list.append(hpp2plantuml.hpp2plantuml.Container(
c_type, c_name))
c_obj_list.sort(key=lambda obj: obj.comparison_keys())
for i in range(len(c_list)):
nt.assert_equal(c_obj_list[i].get_name(),
c_list[ref_sort_idx[i]][1])
示例3: test_list_entries
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_list_entries(self):
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_link)):
obj_d = hpp2plantuml.Diagram(flag_dep=True)
# Not very unittest-y
obj_d.create_from_string(input_str)
if len(obj_d._inheritance_list) > 0:
obj_l = obj_d._inheritance_list[0]
elif len(obj_d._aggregation_list) > 0:
obj_l = obj_d._aggregation_list[0]
elif len(obj_d._dependency_list) > 0:
obj_l = obj_d._dependency_list[0]
nt.assert_equal(output_ref_str, obj_l.render(),
'Test {0} failed [input: {1}]'.format(test_idx,
input_str))
# %% Test overall system
示例4: test_touch_dids_atime
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_touch_dids_atime(self):
""" DATA IDENTIFIERS (CORE): Touch dids accessed_at timestamp"""
tmp_scope = InternalScope('mock')
root = InternalAccount('root')
tmp_dsn1 = 'dsn_%s' % generate_uuid()
tmp_dsn2 = 'dsn_%s' % generate_uuid()
add_did(scope=tmp_scope, name=tmp_dsn1, type=DIDType.DATASET, account=root)
add_did(scope=tmp_scope, name=tmp_dsn2, type=DIDType.DATASET, account=root)
now = datetime.utcnow()
now -= timedelta(microseconds=now.microsecond)
assert_equal(None, get_did_atime(scope=tmp_scope, name=tmp_dsn1))
assert_equal(None, get_did_atime(scope=tmp_scope, name=tmp_dsn2))
touch_dids(dids=[{'scope': tmp_scope, 'name': tmp_dsn1, 'type': DIDType.DATASET, 'accessed_at': now}])
assert_equal(now, get_did_atime(scope=tmp_scope, name=tmp_dsn1))
assert_equal(None, get_did_atime(scope=tmp_scope, name=tmp_dsn2))
示例5: test_touch_dids_access_cnt
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_touch_dids_access_cnt(self):
""" DATA IDENTIFIERS (CORE): Increase dids access_cnt"""
tmp_scope = InternalScope('mock')
root = InternalAccount('root')
tmp_dsn1 = 'dsn_%s' % generate_uuid()
tmp_dsn2 = 'dsn_%s' % generate_uuid()
add_did(scope=tmp_scope, name=tmp_dsn1, type=DIDType.DATASET, account=root)
add_did(scope=tmp_scope, name=tmp_dsn2, type=DIDType.DATASET, account=root)
assert_equal(None, get_did_access_cnt(scope=tmp_scope, name=tmp_dsn1))
assert_equal(None, get_did_access_cnt(scope=tmp_scope, name=tmp_dsn2))
for i in range(100):
touch_dids(dids=[{'scope': tmp_scope, 'name': tmp_dsn1, 'type': DIDType.DATASET}])
assert_equal(100, get_did_access_cnt(scope=tmp_scope, name=tmp_dsn1))
assert_equal(None, get_did_access_cnt(scope=tmp_scope, name=tmp_dsn2))
示例6: test_update_dids
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_update_dids(self):
""" DATA IDENTIFIERS (CORE): Update file size and checksum"""
tmp_scope = InternalScope('mock')
root = InternalAccount('root')
dsn = 'dsn_%s' % generate_uuid()
lfn = 'lfn.%s' % str(generate_uuid())
add_did(scope=tmp_scope, name=dsn, type=DIDType.DATASET, account=root)
files = [{'scope': tmp_scope, 'name': lfn,
'bytes': 724963570, 'adler32': '0cc737eb',
'meta': {'guid': str(generate_uuid()), 'events': 100}}]
attach_dids(scope=tmp_scope, name=dsn, rse_id=get_rse_id(rse='MOCK'), dids=files, account=root)
set_metadata(scope=tmp_scope, name=lfn, key='adler32', value='0cc737ee')
assert_equal(get_metadata(scope=tmp_scope, name=lfn)['adler32'], '0cc737ee')
with assert_raises(DataIdentifierNotFound):
set_metadata(scope=tmp_scope, name='Nimportnawak', key='adler32', value='0cc737ee')
set_metadata(scope=tmp_scope, name=lfn, key='bytes', value=724963577)
assert_equal(get_metadata(scope=tmp_scope, name=lfn)['bytes'], 724963577)
示例7: test_get_did_with_dynamic
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_get_did_with_dynamic(self):
""" DATA IDENTIFIERS (CORE): Get did with dynamic resolve of size"""
tmp_scope = InternalScope('mock')
root = InternalAccount('root')
tmp_dsn1 = 'dsn_%s' % generate_uuid()
tmp_dsn2 = 'dsn_%s' % generate_uuid()
tmp_dsn3 = 'dsn_%s' % generate_uuid()
tmp_dsn4 = 'dsn_%s' % generate_uuid()
rse_id = get_rse_id(rse='MOCK')
add_did(scope=tmp_scope, name=tmp_dsn1, type=DIDType.DATASET, account=root)
add_replica(rse_id=rse_id, scope=tmp_scope, name=tmp_dsn2, bytes=10, account=root)
add_replica(rse_id=rse_id, scope=tmp_scope, name=tmp_dsn3, bytes=10, account=root)
attach_dids(scope=tmp_scope, name=tmp_dsn1, dids=[{'scope': tmp_scope, 'name': tmp_dsn2}, {'scope': tmp_scope, 'name': tmp_dsn3}], account=root)
add_did(scope=tmp_scope, name=tmp_dsn4, type=DIDType.CONTAINER, account=root)
attach_dids(scope=tmp_scope, name=tmp_dsn4, dids=[{'scope': tmp_scope, 'name': tmp_dsn1}], account=root)
assert_equal(get_did(scope=tmp_scope, name=tmp_dsn1, dynamic=True)['bytes'], 20)
assert_equal(get_did(scope=tmp_scope, name=tmp_dsn4, dynamic=True)['bytes'], 20)
示例8: test_remove_did_from_followed
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_remove_did_from_followed(self):
""" DATA IDENTIFIERS (CORE): Mark a did as not followed """
tmp_scope = InternalScope('mock')
dsn = 'dsn_%s' % generate_uuid()
root = InternalAccount('root')
add_did(scope=tmp_scope, name=dsn, type=DIDType.DATASET, account=root)
add_did_to_followed(scope=tmp_scope, name=dsn, account=root)
users = get_users_following_did(scope=tmp_scope, name=dsn)
rows = 0
for user in users:
rows += 1
assert_equal(rows, 1)
remove_did_from_followed(scope=tmp_scope, name=dsn, account=root)
users = get_users_following_did(scope=tmp_scope, name=dsn)
rows = 0
for user in users:
rows += 1
assert_equal(rows, 0)
示例9: test_list_by_length
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_list_by_length(self):
""" DATA IDENTIFIERS (CLIENT): List did with length """
tmp_scope = 'mock'
tmp_dsn = 'dsn_%s' % generate_uuid()
self.did_client.add_dataset(scope=tmp_scope, name=tmp_dsn)
dids = self.did_client.list_dids(tmp_scope, {'length.gt': 0})
results = []
for d in dids:
results.append(d)
assert_not_equal(len(results), 0)
dids = self.did_client.list_dids(tmp_scope, {'length.gt': -1, 'length.lt': 1})
results = []
for d in dids:
results.append(d)
assert_equal(len(results), 0)
dids = self.did_client.list_dids(tmp_scope, {'length': 0})
results = []
for d in dids:
results.append(d)
assert_equal(len(results), 0)
示例10: test_get_did
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_get_did(self):
""" DATA IDENTIFIERS (CLIENT): add a new data identifier and try to retrieve it back"""
rse = 'MOCK'
scope = 'mock'
file = generate_uuid()
dsn = generate_uuid()
self.replica_client.add_replica(rse, scope, file, 1, '0cc737eb')
did = self.did_client.get_did(scope, file)
assert_equal(did['scope'], scope)
assert_equal(did['name'], file)
self.did_client.add_dataset(scope=scope, name=dsn, lifetime=10000000)
did2 = self.did_client.get_did(scope, dsn)
assert_equal(type(did2['expired_at']), datetime)
示例11: test_get_meta
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_get_meta(self):
""" DATA IDENTIFIERS (CLIENT): add a new meta data for an identifier and try to retrieve it back"""
rse = 'MOCK'
scope = 'mock'
file = generate_uuid()
keys = ['project', 'run_number']
values = ['data13_hip', 12345678]
self.replica_client.add_replica(rse, scope, file, 1, '0cc737eb')
for i in range(2):
self.did_client.set_metadata(scope, file, keys[i], values[i])
meta = self.did_client.get_metadata(scope, file)
for i in range(2):
assert_equal(meta[keys[i]], values[i])
示例12: test_update_replicas_paths
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_update_replicas_paths(self):
""" REPLICA (CORE): Force update the replica path """
tmp_scope = InternalScope('mock')
root = InternalAccount('root')
nbfiles = 5
rse_id = get_rse_id(rse='MOCK')
rse_id2 = get_rse_id(rse='MOCK2')
files = [{'scope': tmp_scope,
'name': 'file_%s' % generate_uuid(),
'pfn': 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/does/not/really/matter/where',
'bytes': 1,
'adler32': '0cc737eb',
'meta': {'events': 10},
'rse_id': rse_id,
'path': '/does/not/really/matter/where'} for _ in range(nbfiles)]
add_replicas(rse_id=rse_id2, files=files, account=root, ignore_availability=True)
update_replicas_paths(files)
for replica in list_replicas(dids=[{'scope': f['scope'],
'name': f['name'],
'type': DIDType.FILE} for f in files],
schemes=['srm']):
# force the changed string - if we look it up from the DB, then we're not testing anything :-D
assert_equal(replica['rses'][rse_id2][0], 'srm://mock2.com:8443/srm/managerv2?SFN=/rucio/tmpdisk/rucio_tests/does/not/really/matter/where')
示例13: test_update_lock_counter
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_update_lock_counter(self):
""" RSE (CORE): Test the update of a replica lock counter """
rse = 'MOCK'
rse_id = get_rse_id(rse=rse)
tmp_scope = InternalScope('mock')
tmp_file = 'file_%s' % generate_uuid()
add_replica(rse_id=rse_id, scope=tmp_scope, name=tmp_file, bytes=1, adler32='0cc737eb', account=InternalAccount('jdoe'))
values = (1, 1, 1, -1, -1, -1, 1, 1, -1)
tombstones = (True, True, True, True, True, False, True, True, True)
lock_counters = (1, 2, 3, 2, 1, 0, 1, 2, 1)
for value, tombstone, lock_counter in zip(values, tombstones, lock_counters):
status = update_replica_lock_counter(rse_id=rse_id, scope=tmp_scope, name=tmp_file, value=value)
assert_equal(status, True)
replica = get_replica(rse_id=rse_id, scope=tmp_scope, name=tmp_file)
assert_equal(replica['tombstone'] is None, tombstone)
assert_equal(lock_counter, replica['lock_cnt'])
示例14: test_list_replicas_all_states
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_list_replicas_all_states(self):
""" REPLICA (CORE): list file replicas with all_states"""
tmp_scope = InternalScope('mock')
root = InternalAccount('root')
nbfiles = 13
files = [{'scope': tmp_scope, 'name': 'file_%s' % generate_uuid(), 'bytes': 1, 'adler32': '0cc737eb', 'meta': {'events': 10}} for _ in range(nbfiles)]
rses = [get_rse_id(rse='MOCK'), get_rse_id(rse='MOCK3')]
for rse_id in rses:
add_replicas(rse_id=rse_id, files=files, account=root, ignore_availability=True)
for file in files:
update_replica_state(rses[0], tmp_scope, file['name'], ReplicaState.COPYING)
replica_cpt = 0
for replica in list_replicas(dids=[{'scope': f['scope'], 'name': f['name'], 'type': DIDType.FILE} for f in files], schemes=['srm'], all_states=True):
assert_in('states', replica)
assert_equal(replica['states'][rses[0]], str(ReplicaState.COPYING))
assert_equal(replica['states'][rses[1]], str(ReplicaState.AVAILABLE))
replica_cpt += 1
assert_equal(nbfiles, replica_cpt)
示例15: test_set_tombstone
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equal [as 别名]
def test_set_tombstone(self):
""" REPLICA (CORE): set tombstone on replica """
# Set tombstone on one replica
rse = 'MOCK4'
rse_id = get_rse_id(rse=rse)
scope = InternalScope('mock')
user = InternalAccount('root')
name = generate_uuid()
add_replica(rse_id, scope, name, 4, user)
assert_equal(get_replica(rse_id, scope, name)['tombstone'], None)
set_tombstone(rse_id, scope, name)
assert_equal(get_replica(rse_id, scope, name)['tombstone'], OBSOLETE)
# Set tombstone on locked replica
name = generate_uuid()
add_replica(rse_id, scope, name, 4, user)
RuleClient().add_replication_rule([{'name': name, 'scope': scope.external}], 1, rse, locked=True)
with assert_raises(ReplicaIsLocked):
set_tombstone(rse_id, scope, name)
# Set tombstone on not found replica
name = generate_uuid()
with assert_raises(ReplicaNotFound):
set_tombstone(rse_id, scope, name)