当前位置: 首页>>代码示例>>Python>>正文


Python a.foo方法代码示例

本文整理汇总了Python中x.a.a.foo方法的典型用法代码示例。如果您正苦于以下问题:Python a.foo方法的具体用法?Python a.foo怎么用?Python a.foo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在x.a.a的用法示例。


在下文中一共展示了a.foo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tuple_unpack

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_tuple_unpack(self):
        b = """
            def foo():
                try:
                    pass
                except Exception, (f, e):
                    pass
                except ImportError, e:
                    pass"""

        a = """
            def foo():
                try:
                    pass
                except Exception as xxx_todo_changeme:
                    (f, e) = xxx_todo_changeme.args
                    pass
                except ImportError as e:
                    pass"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:22,代码来源:test_fixers.py

示例2: test_remove_multiple_items

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_remove_multiple_items(self):
        b = """isinstance(x, (int, int, int))"""
        a = """isinstance(x, int)"""
        self.check(b, a)

        b = """isinstance(x, (int, float, int, int, float))"""
        a = """isinstance(x, (int, float))"""
        self.check(b, a)

        b = """isinstance(x, (int, float, int, int, float, str))"""
        a = """isinstance(x, (int, float, str))"""
        self.check(b, a)

        b = """isinstance(foo() + bar(), (x(), y(), x(), int, int))"""
        a = """isinstance(foo() + bar(), (x(), y(), x(), int))"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:18,代码来源:test_fixers.py

示例3: test_wrap_in_list

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_wrap_in_list(self):
        b = """x = range(10, 3, 9)"""
        a = """x = list(range(10, 3, 9))"""
        self.check(b, a)

        b = """x = foo(range(10, 3, 9))"""
        a = """x = foo(list(range(10, 3, 9)))"""
        self.check(b, a)

        b = """x = range(10, 3, 9) + [4]"""
        a = """x = list(range(10, 3, 9)) + [4]"""
        self.check(b, a)

        b = """x = range(10)[::-1]"""
        a = """x = list(range(10))[::-1]"""
        self.check(b, a)

        b = """x = range(10)  [3]"""
        a = """x = list(range(10))  [3]"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:22,代码来源:test_fixers.py

示例4: test_import_from

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_import_from(self):
        for old, changes in self.modules.items():
            all_members = []
            for new, members in changes:
                for member in members:
                    all_members.append(member)
                    b = "from %s import %s" % (old, member)
                    a = "from %s import %s" % (new, member)
                    self.check(b, a)

                    s = "from foo import %s" % member
                    self.unchanged(s)

                b = "from %s import %s" % (old, ", ".join(members))
                a = "from %s import %s" % (new, ", ".join(members))
                self.check(b, a)

                s = "from foo import %s" % ", ".join(members)
                self.unchanged(s)

            # test the breaking of a module into multiple replacements
            b = "from %s import %s" % (old, ", ".join(all_members))
            a = "\n".join(["from %s import %s" % (new, ", ".join(members))
                            for (new, members) in changes])
            self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:27,代码来源:test_fixers.py

示例5: test_indented

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_indented(self):
        b = """
def foo():
    from urllib import urlencode, urlopen
"""
        a = """
def foo():
    from urllib.parse import urlencode
    from urllib.request import urlopen
"""
        self.check(b, a)

        b = """
def foo():
    other()
    from urllib import urlencode, urlopen
"""
        a = """
def foo():
    other()
    from urllib.parse import urlencode
    from urllib.request import urlopen
"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:26,代码来源:test_fixers.py

示例6: test_import_module_usage

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_import_module_usage(self):
        for old, changes in self.modules.items():
            for new, members in changes:
                for member in members:
                    new_import = ", ".join([n for (n, mems)
                                            in self.modules[old]])
                    b = """
                        import %s
                        foo(%s.%s)
                        """ % (old, old, member)
                    a = """
                        import %s
                        foo(%s.%s)
                        """ % (new_import, new, member)
                    self.check(b, a)
                    b = """
                        import %s
                        %s.%s(%s.%s)
                        """ % (old, old, member, old, member)
                    a = """
                        import %s
                        %s.%s(%s.%s)
                        """ % (new_import, new, member, new, member)
                    self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:26,代码来源:test_fixers.py

示例7: test_prefix_preservation_4

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_prefix_preservation_4(self):
        b = """
            next = 5
            for a in b:
                foo(a) # abc
                # def
                a.next()
            """
        a = """
            next = 5
            for a in b:
                foo(a) # abc
                # def
                a.__next__()
            """
        self.check(b, a, ignore_warnings=True) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:18,代码来源:test_fixers.py

示例8: test_method_4

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_method_4(self):
        b = """
            class A:
                def __init__(self, foo):
                    self.foo = foo

                def next(self):
                    pass

                def __iter__(self):
                    return self
            """
        a = """
            class A:
                def __init__(self, foo):
                    self.foo = foo

                def __next__(self):
                    pass

                def __iter__(self):
                    return self
            """
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:26,代码来源:test_fixers.py

示例9: test_while

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_while(self):
        b = """while 1: foo()"""
        a = """while True: foo()"""
        self.check(b, a)

        b = """while   1: foo()"""
        a = """while   True: foo()"""
        self.check(b, a)

        b = """
            while 1:
                foo()
            """
        a = """
            while True:
                foo()
            """
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:20,代码来源:test_fixers.py

示例10: test_weird_comments

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_weird_comments(self):
        b = """apply(   # foo
          f, # bar
          args)"""
        a = """f(*args)"""
        self.check(b, a)

    # These should *not* be touched 
开发者ID:remg427,项目名称:misp42splunk,代码行数:10,代码来源:test_fixers.py

示例11: test_weird_target_2

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_weird_target_2(self):
        b = """
            try:
                pass
            except Exception, a.foo:
                pass"""

        a = """
            try:
                pass
            except Exception as xxx_todo_changeme:
                a.foo = xxx_todo_changeme
                pass"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:16,代码来源:test_fixers.py

示例12: test_weird_target_3

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_weird_target_3(self):
        b = """
            try:
                pass
            except Exception, a().foo:
                pass"""

        a = """
            try:
                pass
            except Exception as xxx_todo_changeme:
                a().foo = xxx_todo_changeme
                pass"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:16,代码来源:test_fixers.py

示例13: test_with_comments

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_with_comments(self):
        b = """raise Exception, 5 # foo"""
        a = """raise Exception(5) # foo"""
        self.check(b, a)

        b = """raise E, (5, 6) % (a, b) # foo"""
        a = """raise E((5, 6) % (a, b)) # foo"""
        self.check(b, a)

        b = """def foo():
                    raise Exception, 5, 6 # foo"""
        a = """def foo():
                    raise Exception(5).with_traceback(6) # foo"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:16,代码来源:test_fixers.py

示例14: test_string_exc_val

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_string_exc_val(self):
        s = """raise "foo", 5"""
        self.warns_unchanged(s, "Python 3 does not support string exceptions") 
开发者ID:remg427,项目名称:misp42splunk,代码行数:5,代码来源:test_fixers.py

示例15: test_string_exc_val_tb

# 需要导入模块: from x.a import a [as 别名]
# 或者: from x.a.a import foo [as 别名]
def test_string_exc_val_tb(self):
        s = """raise "foo", 5, 6"""
        self.warns_unchanged(s, "Python 3 does not support string exceptions")

    # These should result in traceback-assignment 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:test_fixers.py


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