本文整理汇总了Python中mypy.myunit.assert_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_equal函数的具体用法?Python assert_equal怎么用?Python assert_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_parse_all_signatures
def test_parse_all_signatures(self):
assert_equal(parse_all_signatures(['random text',
'.. function:: fn(arg',
'.. function:: fn()',
' .. method:: fn2(arg)']),
([('fn', '()'),
('fn2', '(arg)')], []))
开发者ID:rockneurotiko,项目名称:mypy,代码行数:7,代码来源:teststubgen.py
示例2: test_as_xml
def test_as_xml(self) -> None:
cobertura_package = CoberturaPackage('foobar')
cobertura_package.covered_lines = 21
cobertura_package.total_lines = 42
child_package = CoberturaPackage('raz')
child_package.covered_lines = 10
child_package.total_lines = 10
child_package.classes['class'] = etree.Element('class')
cobertura_package.packages['raz'] = child_package
expected_output = textwrap.dedent('''\
<package complexity="1.0" name="foobar" branch-rate="0" line-rate="0.5000">
<classes/>
<packages>
<package complexity="1.0" name="raz" branch-rate="0" line-rate="1.0000">
<classes>
<class/>
</classes>
</package>
</packages>
</package>
''').encode('ascii')
assert_equal(expected_output,
etree.tostring(cobertura_package.as_xml(), pretty_print=True))
开发者ID:greatmazinger,项目名称:mypy,代码行数:26,代码来源:testreports.py
示例3: test_coherence
def test_coherence(self):
# We have to special case Options.BuildType because we're required to
# set a target
options = Options()
options.build_type = BuildType.PROGRAM_TEXT
_, parsed_options = process_options(['-c', 'cmd'])
assert_equal(options, parsed_options)
开发者ID:pgjones,项目名称:mypy,代码行数:7,代码来源:testargs.py
示例4: test_callable_type_with_default_args
def test_callable_type_with_default_args(self):
c = CallableType([self.x, self.y], [ARG_POS, ARG_OPT], [None, None],
AnyType(), self.function)
assert_equal(str(c), 'def (X?, Y? =) -> Any')
c2 = CallableType([self.x, self.y], [ARG_OPT, ARG_OPT], [None, None],
AnyType(), self.function)
assert_equal(str(c2), 'def (X? =, Y? =) -> Any')
开发者ID:o11c,项目名称:mypy,代码行数:8,代码来源:testtypes.py
示例5: test_false_only_of_instance
def test_false_only_of_instance(self):
fo = false_only(self.fx.a)
assert_equal(str(fo), "A")
assert_false(fo.can_be_true)
assert_true(fo.can_be_false)
assert_type(Instance, fo)
# The original class still can be true
assert_true(self.fx.a.can_be_true)
开发者ID:AXGKl,项目名称:Transcrypt,代码行数:8,代码来源:testtypes.py
示例6: test_topsort
def test_topsort(self) -> None:
a = frozenset({"A"})
b = frozenset({"B"})
c = frozenset({"C"})
d = frozenset({"D"})
data = {a: {b, c}, b: {d}, c: {d}} # type: Dict[AbstractSet[str], Set[AbstractSet[str]]]
res = list(topsort(data))
assert_equal(res, [{d}, {b, c}, {a}])
开发者ID:judasnow,项目名称:mypy,代码行数:8,代码来源:testgraph.py
示例7: test_true_only_of_instance
def test_true_only_of_instance(self):
to = true_only(self.fx.a)
assert_equal(str(to), "A")
assert_true(to.can_be_true)
assert_false(to.can_be_false)
assert_type(Instance, to)
# The original class still can be false
assert_true(self.fx.a.can_be_false)
开发者ID:AXGKl,项目名称:Transcrypt,代码行数:8,代码来源:testtypes.py
示例8: assert_expand
def assert_expand(self, orig, map_items, result):
lower_bounds = {}
for id, t in map_items:
lower_bounds[id] = t
exp = expand_type(orig, lower_bounds)
# Remove erased tags (asterisks).
assert_equal(str(exp).replace('*', ''), str(result))
开发者ID:o11c,项目名称:mypy,代码行数:9,代码来源:testtypes.py
示例9: test_callable_type
def test_callable_type(self):
c = CallableType([self.x, self.y],
[ARG_POS, ARG_POS],
[None, None],
AnyType(), self.function)
assert_equal(str(c), 'def (X?, Y?) -> Any')
c2 = CallableType([], [], [], Void(None), False)
assert_equal(str(c2), 'def ()')
开发者ID:o11c,项目名称:mypy,代码行数:9,代码来源:testtypes.py
示例10: test_find_unique_signatures
def test_find_unique_signatures(self):
assert_equal(find_unique_signatures(
[('func', '()'),
('func', '()'),
('func2', '()'),
('func2', '(arg)'),
('func3', '(arg, arg2)')]),
[('func', '()'),
('func3', '(arg, arg2)')])
开发者ID:rockneurotiko,项目名称:mypy,代码行数:9,代码来源:teststubgen.py
示例11: assert_vararg_map
def assert_vararg_map(self, caller_kinds, callee_kinds, expected,
vararg_type):
result = map_actuals_to_formals(
caller_kinds,
[],
callee_kinds,
[],
lambda i: vararg_type)
assert_equal(result, expected)
开发者ID:Varriount,项目名称:mypy,代码行数:9,代码来源:testinfer.py
示例12: test_generic_function_type
def test_generic_function_type(self):
c = Callable([self.x, self.y], [ARG_POS, ARG_POS], [None, None],
self.y, False, None,
[TypeVarDef('X', -1, None)])
assert_equal(str(c), 'def [X] (X?, Y?) -> Y?')
v = [TypeVarDef('Y', -1, None), TypeVarDef('X', -2, None)]
c2 = Callable([], [], [], Void(None), False, None, v)
assert_equal(str(c2), 'def [Y, X] ()')
开发者ID:bussiere,项目名称:mypy,代码行数:9,代码来源:testtypes.py
示例13: assert_solve
def assert_solve(self, vars, constraints, results):
res = []
for r in results:
if isinstance(r, tuple):
res.append(r[0])
else:
res.append(r)
actual = solve_constraints(vars, constraints)
assert_equal(str(actual), str(res))
开发者ID:narusemotoki,项目名称:mypy,代码行数:9,代码来源:testsolve.py
示例14: test_sorted_components
def test_sorted_components(self) -> None:
manager = self._make_manager()
graph = {'a': State('a', None, 'import b, c', manager),
'd': State('d', None, 'pass', manager),
'b': State('b', None, 'import c', manager),
'c': State('c', None, 'import b, d', manager),
}
res = sorted_components(graph)
assert_equal(res, [frozenset({'d'}), frozenset({'c', 'b'}), frozenset({'a'})])
开发者ID:greatmazinger,项目名称:mypy,代码行数:9,代码来源:testgraph.py
示例15: test_generic_function_type
def test_generic_function_type(self) -> None:
c = CallableType([self.x, self.y], [ARG_POS, ARG_POS], [None, None],
self.y, self.function, name=None,
variables=[TypeVarDef('X', -1, None, self.fx.o)])
assert_equal(str(c), 'def [X] (X?, Y?) -> Y?')
v = [TypeVarDef('Y', -1, None, self.fx.o),
TypeVarDef('X', -2, None, self.fx.o)]
c2 = CallableType([], [], [], Void(None), self.function, name=None, variables=v)
assert_equal(str(c2), 'def [Y, X] ()')
开发者ID:alexandrul,项目名称:mypy,代码行数:10,代码来源:testtypes.py
示例16: assert_map
def assert_map(self, caller_kinds, callee_kinds, expected):
caller_kinds, caller_names = expand_caller_kinds(caller_kinds)
callee_kinds, callee_names = expand_callee_kinds(callee_kinds)
result = map_actuals_to_formals(
caller_kinds,
caller_names,
callee_kinds,
callee_names,
lambda i: Any())
assert_equal(result, expected)
开发者ID:Varriount,项目名称:mypy,代码行数:10,代码来源:testinfer.py
示例17: test_generic_function_type
def test_generic_function_type(self):
c = Callable([self.x, self.y], [ARG_POS, ARG_POS], [None, None],
self.y, False, None,
TypeVars([TypeVarDef('X', -1)]))
assert_equal(str(c), 'def <X> (X?, Y?) -> Y?')
v = TypeVars([TypeVarDef('Y', -1, UnboundType('X')),
TypeVarDef('X', -2)])
c2 = Callable([], [], [], Void(None), False, None, v)
assert_equal(str(c2), 'def <Y is X?, X> ()')
开发者ID:SRiikonen,项目名称:mypy,代码行数:10,代码来源:testtypes.py
示例18: test_true_only_of_union
def test_true_only_of_union(self):
tup_type = self.tuple(AnyType())
# Union of something that is unknown, something that is always true, something
# that is always false
union_type = UnionType([self.fx.a, tup_type, self.tuple()])
to = true_only(union_type)
assert_equal(len(to.items), 2)
assert_true(to.items[0].can_be_true)
assert_false(to.items[0].can_be_false)
assert_true(to.items[1] is tup_type)
开发者ID:AXGKl,项目名称:Transcrypt,代码行数:10,代码来源:testtypes.py
示例19: test_scc
def test_scc(self) -> None:
vertices = {'A', 'B', 'C', 'D'}
edges = {'A': ['B', 'C'],
'B': ['C'],
'C': ['B', 'D'],
'D': []} # type: Dict[str, List[str]]
sccs = set(frozenset(x) for x in strongly_connected_components(vertices, edges))
assert_equal(sccs,
{frozenset({'A'}),
frozenset({'B', 'C'}),
frozenset({'D'})})
开发者ID:greatmazinger,项目名称:mypy,代码行数:11,代码来源:testgraph.py
示例20: test_false_only_of_union
def test_false_only_of_union(self) -> None:
tup_type = self.tuple()
# Union of something that is unknown, something that is always true, something
# that is always false
union_type = UnionType([self.fx.a, self.tuple(AnyType()), tup_type])
assert_equal(len(union_type.items), 3)
fo = false_only(union_type)
assert isinstance(fo, UnionType)
assert_equal(len(fo.items), 2)
assert_false(fo.items[0].can_be_true)
assert_true(fo.items[0].can_be_false)
assert_true(fo.items[1] is tup_type)
开发者ID:alexandrul,项目名称:mypy,代码行数:12,代码来源:testtypes.py
注:本文中的mypy.myunit.assert_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论