本文整理汇总了Python中nose.tools.assert_multi_line_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_multi_line_equal函数的具体用法?Python assert_multi_line_equal怎么用?Python assert_multi_line_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_multi_line_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test_good
def _test_good(self, filename):
base_name, _ = os.path.splitext(filename)
input_filename = base_name + '.input'
if not os.path.exists(input_filename):
input_filename = os.devnull
output_filename = base_name + '.output'
rc, stderr = self._compile(filename)
stderr = stderr.decode()
assert_multi_line_equal(stderr, '')
assert_equal(rc, 0)
with open(input_filename, 'rb') as input_file:
child = ipc.Popen(self.runner + [self.executable],
stdin=input_file,
stdout=ipc.PIPE,
stderr=ipc.PIPE
)
stdout = child.stdout.read()
stderr = child.stderr.read()
rc = child.wait()
stderr = stderr.decode()
assert_multi_line_equal(stderr, '')
assert_equal(rc, 0)
with open(output_filename, 'rb') as output_file:
expected_stdout = output_file.read()
assert_equal(expected_stdout, stdout)
示例2: test_convert_to_docstring
def test_convert_to_docstring():
assert_equal(convert_to_docstring(None), "")
assert_multi_line_equal(
convert_to_docstring(lines(
"/**",
" * This is a brief comment.",
" */")),
"This is a brief comment."
)
assert_multi_line_equal(
convert_to_docstring("/// This is a brief comment."),
"This is a brief comment."
)
assert_multi_line_equal(
convert_to_docstring(lines(
"/**",
" * This is a brief comment.",
" *",
" * This is a detailed comment.",
" */")
),
lines(
"This is a brief comment.",
"",
"This is a detailed comment.")
)
assert_multi_line_equal(
convert_to_docstring(lines(
"/**",
" * This is a brief comment.",
" * This is a detailed comment.",
" */")
),
lines(
"This is a brief comment.",
"",
"This is a detailed comment.")
)
assert_multi_line_equal(
convert_to_docstring(lines(
"/**",
" * This is a brief comment.",
" * ",
" * This is a detailed comment.",
" * It contains mathematical equations, like 2 * 3 + 5 = 11.",
" * It is important that it includes '*'. 5x * 3x*y = y*z!"
" */")
),
lines(
"This is a brief comment.",
"",
"This is a detailed comment.",
"It contains mathematical equations, like 2 * 3 + 5 = 11.",
"It is important that it includes '*'. 5x * 3x*y = y*z!")
)
示例3: test_semanticizer_nlwiki
def test_semanticizer_nlwiki():
tempfile = NamedTemporaryFile()
db = create_model(join(dirname(__file__),
'nlwiki-20140927-pages-articles-sample.xml'),
tempfile.name)
sem = Semanticizer(tempfile.name)
dirs = {d: join(dirname(__file__), 'nlwiki', d)
for d in "in expected actual".split()}
input_test_cases = glob(join(dirs['in'], '*'))
assert_equal(len(input_test_cases), 20,
msg=("number of input test cases in %r should be 20"
% dirs['in']))
for doc in input_test_cases:
fname = basename(doc)
with open(doc) as f:
with open(join(dirs['actual'], fname), 'w') as out:
tokens = f.read().split()
out.write("\n".join(str(cand)
for cand in sem.all_candidates(tokens)))
with open(join(dirs['expected'], fname)) as f:
expected = f.read()
with open(join(dirs['actual'], fname)) as f:
actual = f.read()
assert_multi_line_equal(expected,
actual)
示例4: _test
def _test(format):
pandoc_output = call_pandoc(format)
ref_file = 'tests/spec.{ext}'.format(ext=format)
with open(ref_file) as f:
nt.assert_multi_line_equal(pandoc_output, f.read())
示例5: test_function_string_with_return
def test_function_string_with_return():
f = Function("test.hpp", "", "my_fun", "double")
assert_multi_line_equal(
str(f), lines(
"Function 'my_fun'",
" Returns (double)"
)
)
示例6: test_notedown
def test_notedown():
"""Integration test the whole thing."""
from difflib import ndiff
notebook = create_json_notebook(sample_markdown)
diff = ndiff(sample_notebook.splitlines(1), notebook.splitlines(1))
print '\n'.join(diff)
nt.assert_multi_line_equal(create_json_notebook(sample_markdown),
sample_notebook)
示例7: test_make_header
def test_make_header():
assert_multi_line_equal(
make_header("a b c d"),
lines(
"+" + "=" * 78 + "+",
"| a b c d" + " " * 70 + "|",
"+" + "=" * 78 + "+"
)
)
示例8: test_template_class_string
def test_template_class_string():
c = TemplateClass("test.hpp", "", "MyTemplateClass")
c.template_types.append("T")
assert_multi_line_equal(
str(c), lines(
"TemplateClass 'MyTemplateClass' ('MyTemplateClass')",
" Template type 'T'"
)
)
示例9: test_write_table2
def test_write_table2(self):
import os
TestObsTable.obstable.add_records_to_table([TestObsTable.obsrecord,TestObsTable.obsrecord])
TestObsTable.obstable.filename = 'testtable2.dat'
TestObsTable.obstable.write_table()
expected_result = open(TestObsTable.filename, 'r').read()
result = open('testtable2.dat', 'r').read()
os.remove('testtable2.dat')
assert_multi_line_equal(result, expected_result)
示例10: test_simple_function_def
def test_simple_function_def():
method = MethodDefinition(
"Testclass", "", "testfun", [], Includes(),
"void", TypeInfo({}), Config()).make()
assert_multi_line_equal(
method,
lines("cpdef testfun(Testclass self):",
" self.thisptr.testfun()")
)
示例11: _test_bad
def _test_bad(self, filename):
base_name, _ = os.path.splitext(filename)
error_filename = base_name + '.error'
rc, stderr = self._compile(filename, output_filename=os.devnull)
stderr = stderr.decode()
assert_not_equal(rc, 0)
with open(error_filename, 'r') as error_file:
expected_stderr = error_file.read()
assert_multi_line_equal(expected_stderr, stderr)
示例12: test_array_arg_function_def
def test_array_arg_function_def():
method = MethodDefinition(
"Testclass", "", "testfun", [Param("a", "double *"),
Param("aSize", "unsigned int")],
Includes(), "void", TypeInfo({}), Config()).make()
assert_multi_line_equal(
method,
lines("cpdef testfun(Testclass self, np.ndarray[double, ndim=1] a):",
" self.thisptr.testfun(&a[0], a.shape[0])")
)
示例13: test_default_ctor_def
def test_default_ctor_def():
ctor = ConstructorDefinition("MyClass", "", [], Includes(), TypeInfo(),
Config(), "MyClass").make()
assert_multi_line_equal(
ctor,
lines(
"def __init__(MyClass self):",
" self.thisptr = new cpp.MyClass()"
)
)
示例14: test_function_def_with_another_cppname
def test_function_def_with_another_cppname():
fun = FunctionDefinition("myFunInt", "", [], Includes(), "void", TypeInfo(),
Config(), cppname="myFun").make()
assert_multi_line_equal(
fun,
lines(
"cpdef my_fun_int():",
" cpp.myFun()"
)
)
示例15: test_function_def
def test_function_def():
fun = FunctionDefinition("myFun", "", [], Includes(), "void", TypeInfo(),
Config()).make()
assert_multi_line_equal(
fun,
lines(
"cpdef my_fun():",
" cpp.myFun()"
)
)