• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python helpers.assert_equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mypy.test.helpers.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) -> None:
     assert_equal(parse_all_signatures(['random text',
                                        '.. function:: fn(arg',
                                        '.. function:: fn()',
                                        '  .. method:: fn2(arg)']),
                  ([('fn', '()'),
                    ('fn2', '(arg)')], []))
开发者ID:sixolet,项目名称:mypy,代码行数:7,代码来源:teststubgen.py


示例2: test_generate_c_type_stub_no_crash_for_object

 def test_generate_c_type_stub_no_crash_for_object(self) -> None:
     output = []  # type: List[str]
     mod = ModuleType('module', '')  # any module is fine
     imports = []  # type: List[str]
     generate_c_type_stub(mod, 'alias', object, output, imports)
     assert_equal(imports, [])
     assert_equal(output[0], 'class alias:')
开发者ID:Michael0x2a,项目名称:mypy,代码行数:7,代码来源:teststubgen.py


示例3: test_generate_c_type_with_overload_pybind11

    def test_generate_c_type_with_overload_pybind11(self) -> None:
        class TestClass:
            def __init__(self, arg0: str) -> None:
                """
                __init__(*args, **kwargs)
                Overloaded function.

                1. __init__(self: TestClass, arg0: str) -> None

                2. __init__(self: TestClass, arg0: str, arg1: str) -> None
                """
                pass
        output = []  # type: List[str]
        imports = []  # type: List[str]
        mod = ModuleType(TestClass.__module__, '')
        generate_c_function_stub(mod, '__init__', TestClass.__init__, output, imports,
                                 self_var='self', class_name='TestClass')
        assert_equal(output, [
            '@overload',
            'def __init__(self, arg0: str) -> None: ...',
            '@overload',
            'def __init__(self, arg0: str, arg1: str) -> None: ...',
            '@overload',
            'def __init__(*args, **kwargs) -> Any: ...'])
        assert_equal(set(imports), {'from typing import overload'})
开发者ID:Michael0x2a,项目名称:mypy,代码行数:25,代码来源:teststubgen.py


示例4: test_false_only_of_instance

 def test_false_only_of_instance(self) -> None:
     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:python,项目名称:mypy,代码行数:8,代码来源:testtypes.py


示例5: test_callable_type_with_default_args

    def test_callable_type_with_default_args(self) -> None:
        c = CallableType([self.x, self.y], [ARG_POS, ARG_OPT], [None, None],
                     AnyType(TypeOfAny.special_form), self.function)
        assert_equal(str(c), 'def (X?, Y? =) -> Any')

        c2 = CallableType([self.x, self.y], [ARG_OPT, ARG_OPT], [None, None],
                      AnyType(TypeOfAny.special_form), self.function)
        assert_equal(str(c2), 'def (X? =, Y? =) -> Any')
开发者ID:python,项目名称:mypy,代码行数: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:Michael0x2a,项目名称:mypy,代码行数:8,代码来源:testgraph.py


示例7: test_true_only_of_instance

 def test_true_only_of_instance(self) -> None:
     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:python,项目名称:mypy,代码行数:8,代码来源:testtypes.py


示例8: test_find_unique_signatures

 def test_find_unique_signatures(self) -> None:
     assert_equal(find_unique_signatures(
         [('func', '()'),
          ('func', '()'),
          ('func2', '()'),
          ('func2', '(arg)'),
          ('func3', '(arg, arg2)')]),
         [('func', '()'),
          ('func3', '(arg, arg2)')])
开发者ID:sixolet,项目名称:mypy,代码行数:9,代码来源:teststubgen.py


示例9: 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:Michael0x2a,项目名称:mypy,代码行数:9,代码来源:testgraph.py


示例10: test_callable_type

    def test_callable_type(self) -> None:
        c = CallableType([self.x, self.y],
                         [ARG_POS, ARG_POS],
                         [None, None],
                         AnyType(TypeOfAny.special_form), self.function)
        assert_equal(str(c), 'def (X?, Y?) -> Any')

        c2 = CallableType([], [], [], NoneType(), self.fx.function)
        assert_equal(str(c2), 'def ()')
开发者ID:python,项目名称:mypy,代码行数:9,代码来源:testtypes.py


示例11: test_infer_arg_sig_from_docstring

    def test_infer_arg_sig_from_docstring(self) -> None:
        assert_equal(infer_arg_sig_from_docstring("(*args, **kwargs)"),
                     [ArgSig(name='*args'), ArgSig(name='**kwargs')])

        assert_equal(
            infer_arg_sig_from_docstring(
                "(x: Tuple[int, Tuple[str, int], str]=(1, ('a', 2), 'y'), y: int=4)"),
            [ArgSig(name='x', type='Tuple[int,Tuple[str,int],str]', default=True),
             ArgSig(name='y', type='int', default=True)])
开发者ID:Michael0x2a,项目名称:mypy,代码行数:9,代码来源:teststubgen.py


示例12: test_generate_c_type_stub_variable_type_annotation

    def test_generate_c_type_stub_variable_type_annotation(self) -> None:
        # This class mimics the stubgen unit test 'testClassVariable'
        class TestClassVariableCls:
            x = 1

        output = []  # type: List[str]
        mod = ModuleType('module', '')  # any module is fine
        generate_c_type_stub(mod, 'C', TestClassVariableCls, output)
        assert_equal(output, ['class C:', '    x: Any = ...'])
开发者ID:sixolet,项目名称:mypy,代码行数:9,代码来源:teststubgen.py


示例13: assert_simple_meet

 def assert_simple_meet(self, s: Type, t: Type, meet: Type) -> None:
     result = meet_types(s, t)
     actual = str(result)
     expected = str(meet)
     assert_equal(actual, expected,
                  'meet({}, {}) == {{}} ({{}} expected)'.format(s, t))
     assert_true(is_subtype(result, s),
                 '{} not subtype of {}'.format(result, s))
     assert_true(is_subtype(result, t),
                 '{} not subtype of {}'.format(result, t))
开发者ID:python,项目名称:mypy,代码行数:10,代码来源:testtypes.py


示例14: 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', 'X', -1, [], self.fx.o)])
        assert_equal(str(c), 'def [X] (X?, Y?) -> Y?')

        v = [TypeVarDef('Y', 'Y', -1, [], self.fx.o),
             TypeVarDef('X', 'X', -2, [], self.fx.o)]
        c2 = CallableType([], [], [], NoneType(), self.function, name=None, variables=v)
        assert_equal(str(c2), 'def [Y, X] ()')
开发者ID:python,项目名称:mypy,代码行数:10,代码来源:testtypes.py


示例15: assert_simple_join

 def assert_simple_join(self, s: Type, t: Type, join: Type) -> None:
     result = join_types(s, t)
     actual = str(result)
     expected = str(join)
     assert_equal(actual, expected,
                  'join({}, {}) == {{}} ({{}} expected)'.format(s, t))
     assert_true(is_subtype(s, result),
                 '{} not subtype of {}'.format(s, result))
     assert_true(is_subtype(t, result),
                 '{} not subtype of {}'.format(t, result))
开发者ID:python,项目名称:mypy,代码行数:10,代码来源:testtypes.py


示例16: test_generate_c_type_inheritance

    def test_generate_c_type_inheritance(self) -> None:
        class TestClass(KeyError):
            pass

        output = []  # type: List[str]
        imports = []  # type: List[str]
        mod = ModuleType('module, ')
        generate_c_type_stub(mod, 'C', TestClass, output, imports)
        assert_equal(output, ['class C(KeyError): ...', ])
        assert_equal(imports, [])
开发者ID:Michael0x2a,项目名称:mypy,代码行数:10,代码来源:teststubgen.py


示例17: 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:Michael0x2a,项目名称:mypy,代码行数:11,代码来源:testgraph.py


示例18: test_true_only_of_union

 def test_true_only_of_union(self) -> None:
     tup_type = self.tuple(AnyType(TypeOfAny.special_form))
     # 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 isinstance(to, UnionType)
     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:python,项目名称:mypy,代码行数:11,代码来源:testtypes.py


示例19: test_order_ascc

 def test_order_ascc(self) -> None:
     manager = self._make_manager()
     graph = {'a': State('a', None, 'import b, c', manager),
              'd': State('d', None, 'def f(): import a', manager),
              'b': State('b', None, 'import c', manager),
              'c': State('c', None, 'import b, d', manager),
              }
     res = sorted_components(graph)
     assert_equal(res, [frozenset({'a', 'd', 'c', 'b'})])
     ascc = res[0]
     scc = order_ascc(graph, ascc)
     assert_equal(scc, ['d', 'c', 'b', 'a'])
开发者ID:Michael0x2a,项目名称:mypy,代码行数:12,代码来源:testgraph.py


示例20: test_generate_c_type_inheritance_other_module

    def test_generate_c_type_inheritance_other_module(self) -> None:
        import argparse

        class TestClass(argparse.Action):
            pass

        output = []  # type: List[str]
        imports = []  # type: List[str]
        mod = ModuleType('module', '')
        generate_c_type_stub(mod, 'C', TestClass, output, imports)
        assert_equal(output, ['class C(argparse.Action): ...', ])
        assert_equal(imports, ['import argparse'])
开发者ID:Michael0x2a,项目名称:mypy,代码行数:12,代码来源:teststubgen.py



注:本文中的mypy.test.helpers.assert_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.assert_string_arrays_equal函数代码示例发布时间:2022-05-27
下一篇:
Python data.parse_test_cases函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap