本文整理汇总了Python中nose.tools.assert_eq函数的典型用法代码示例。如果您正苦于以下问题:Python assert_eq函数的具体用法?Python assert_eq怎么用?Python assert_eq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_eq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_postings_file_get_entry_reset_false
def test_postings_file_get_entry_reset_false():
filename = 'test'
with PostingsFile(filename, 'w+') as pfile:
head = pfile.pointer
prev_ptr = head
last = 12
for i in xrange(1, last):
current_entry = PostingsFileEntry(i)
current_entry.own_pointer = pfile.pointer
pfile.write_entry(current_entry)
if i != last - 1:
current_entry.next_pointer = pfile.pointer
pfile.write_entry(current_entry)
entries = []
entry = pfile.get_entry(head, reset=False)
while entry:
entries.append(entry)
entry = entry.next()
entries = [entry.doc_id for entry in entries]
assert_eq([1,2,3,4,5,6,7,8,9,10,11], entries)
os.remove(filename)
示例2: test_postings_file_seek
def test_postings_file_seek():
filename = 'test'
with PostingsFile(filename, 'w+') as pfile:
assert_eq(0, pfile.pointer)
pfile.seek(10)
assert_eq(10, pfile.pointer)
os.remove(filename)
示例3: test_dot_product_generators
def test_dot_product_generators():
vals = [0,1,2,3,4]
v1 = (x for x in vals)
v2 = (x for x in vals)
assert_eq(
1 + 4 + 9 + 16,
dot_product(v1, v2))
示例4: test_runner_ascii
def test_runner_ascii(patched_func):
cmd = ['cat', os.path.join(TEST_DIR,'ascii_text.txt')]
for line in run_command(cmd):
if type(line) == int:
assert_eq(line, 0)
else:
assert_eq(line.rstrip(), 'Hello ASCII!')
示例5: test_runner_unicode
def test_runner_unicode(patched_func):
cmd = ['cat', os.path.join(TEST_DIR,'unicode_text.txt')]
for line in run_command(cmd):
if type(line) == int:
assert_eq(line, 0)
else:
if line.rstrip() != 'Hello Unicode\u203d':
print('WARNING: Unicode reading not supported!')
示例6: test_unit_vector_generator
def test_unit_vector_generator():
vals = [0,1,2,3,4]
vector = (x for x in vals)
length = math.sqrt(1 + 4 + 9 + 16)
assert_eq(
(float(0)/length, float(1)/length, float(2)/length, float(3)/length,
float(4)/length),
tuple(unit_vector(vector)))
示例7: test_ordered_dict_get_item
def test_ordered_dict_get_item():
o = OrderedDict()
o['a'] = 1
o['b'] = 'asdf'
assert_eq(1, o['a'])
assert_eq(1, o.get('a'))
assert_eq('asdf', o['b'])
assert_eq('asdf', o.get('b'))
assert_eq(None, o.get('c'))
示例8: test_cache_box_is_cached
def test_cache_box_is_cached():
def test_func(x):
return x
cached_test_func = CacheBox(test_func)
assert not cached_test_func.is_cached(5)
assert_eq(5, cached_test_func(5))
assert cached_test_func.is_cached(5)
assert not cached_test_func.is_cached(4)
示例9: test_unit_vector_multiple
def test_unit_vector_multiple():
vector = (1, 2)
length = math.sqrt(1**2 + 2**2)
assert_eq(
(float(1)/length, float(2)/length),
tuple(unit_vector(vector)))
vector = (3, 5)
length = math.sqrt(3**2 + 5**2)
assert_eq(
(float(3)/length, float(5)/length),
tuple(unit_vector(vector)))
示例10: test_cache_decorators
def test_cache_decorators():
@cached_function()
def foo():
return 1
@cached_function(cache_size=10)
def bar():
return 1
assert_eq('foo', foo.__name__)
assert_eq('bar', bar.__name__)
示例11: test_ordered_dict_set_item
def test_ordered_dict_set_item():
o = OrderedDict()
o['a'] = 1
o['b'] = 'asdf'
assert_eq(1, o['a'])
assert_eq('asdf', o['b'])
try:
o['c']
assert False, 'Should throw key error'
except KeyError:
pass
示例12: test_postings_file_write_entry_overwrite
def test_postings_file_write_entry_overwrite():
filename = 'test'
with PostingsFile(filename, 'w+') as pfile:
assert_eq(0, pfile.pointer)
write_location = 0
entry = PostingsFileEntry(1)
entry.own_pointer = write_location
pfile.write_entry(entry)
assert_eq(
PostingsFileEntry(1).to_string(),
pfile.read_entry(write_location))
entry.next_pointer = 2
pfile.write_entry(entry)
assert_eq(
PostingsFileEntry(1, 2).to_string(),
pfile.read_entry(write_location))
entry.skip_pointer = 3
pfile.write_entry(entry)
assert_eq(
PostingsFileEntry(1, 2, 3).to_string(),
pfile.read_entry(write_location))
os.remove(filename)
示例13: test_postings_file_get_entry
def test_postings_file_get_entry():
filename = 'test'
with PostingsFile(filename, 'w+') as pfile:
head = pfile.pointer
pfile.write_entry(PostingsFileEntry(1))
# Test that we set the entries own pointer.
assert_eq(head, pfile.get_entry(head).own_pointer)
ptr = pfile.pointer
pfile.write_entry(PostingsFileEntry(2))
assert_eq(ptr, pfile.get_entry(ptr).own_pointer)
os.remove(filename)
示例14: test_infix_to_prefix_complex
def test_infix_to_prefix_complex():
query = 'a AND b OR c'
assert_eq(['OR', 'AND', 'a', 'b', 'c'], infix_to_prefix(query))
query = 'a AND NOT b'
assert_eq(['AND', 'a', 'NOT', 'b'], infix_to_prefix(query))
query = 'a AND NOT b OR c'
assert_eq(['OR', 'AND', 'a', 'NOT', 'b', 'c'], infix_to_prefix(query))
query = 'a AND (NOT b) OR c'
assert_eq(['OR', 'AND', 'a', 'NOT', 'b', 'c'], infix_to_prefix(query))
query = 'a AND (b OR NOT c) AND d'
assert_eq(['AND', 'a', 'AND', 'OR', 'b', 'NOT', 'c', 'd'], infix_to_prefix(query))
示例15: test_postings_file_get_entry_from_pointer
def test_postings_file_get_entry_from_pointer():
filename = 'test'
with PostingsFile(filename, 'w+') as pfile:
head = pfile.pointer
prev_ptr = head
pfile.write_entry(1)
for i in xrange(10):
next_ptr = pfile.pointer
pfile.write_entry(i + 1, next_ptr, write_location=prev_ptr)
pfile.write_entry(i + 2, write_location=next_ptr)
prev_ptr = next_ptr
entries = pfile.get_entry_list_from_pointer(head)
entries = [entry.doc_id for entry in entries]
assert_eq([1,2,3,4,5,6,7,8,9,10,11], entries)
os.remove(filename)