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


Python foo.baz方法代码示例

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


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

示例1: test_I250_from_fail_2

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_I250_from_fail_2(flake8dir):
    flake8dir.make_example_py(
        """
        from foo import bar as bar, baz as baz

        bar
        baz
    """
    )
    result = flake8dir.run_flake8()
    assert set(result.out_lines) == {
        (
            "./example.py:1:1: I250 Unnecessary import alias - rewrite as "
            + "'from foo import bar'."
        ),
        (
            "./example.py:1:1: I250 Unnecessary import alias - rewrite as "
            + "'from foo import baz'."
        ),
    }


# I251 
开发者ID:adamchainz,项目名称:flake8-tidy-imports,代码行数:25,代码来源:test_flake8_tidy_imports.py

示例2: test_withStatementUndefinedInExpression

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_withStatementUndefinedInExpression(self):
        """
        An undefined name warning is emitted if a name in the I{test}
        expression of a C{with} statement is undefined.
        """
        self.flakes('''
        from __future__ import with_statement
        with bar as baz:
            pass
        ''', m.UndefinedName)

        self.flakes('''
        from __future__ import with_statement
        with bar as bar:
            pass
        ''', m.UndefinedName) 
开发者ID:PyCQA,项目名称:pyflakes,代码行数:18,代码来源:test_other.py

示例3: test_module_attribute_as_usage

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_module_attribute_as_usage(self):
        python_node = self.get_ast_node(
            """
            import foo.bar as baz

            var = 'echo "TEST"'

            baz.qux(var)
            """
        )

        linter = get_bad_module_attribute_use_implementation({'foo.bar': ['qux']})
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=linter._error_tmpl
            )
        ]

        assert result == expected 
开发者ID:duo-labs,项目名称:dlint,代码行数:26,代码来源:test_bad_module_attribute_use.py

示例4: test_module_attribute_import_from_as_usage

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_module_attribute_import_from_as_usage(self):
        python_node = self.get_ast_node(
            """
            from foo.bar import baz as qux

            var = 'echo "TEST"'

            qux(var)
            """
        )

        linter = get_bad_module_attribute_use_implementation({'foo.bar': ['baz']})
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=linter._error_tmpl
            )
        ]

        assert result == expected 
开发者ID:duo-labs,项目名称:dlint,代码行数:26,代码来源:test_bad_module_attribute_use.py

示例5: test_module_attribute_missing_import_usage

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_module_attribute_missing_import_usage(self):
        python_node = self.get_ast_node(
            """
            import baz
            from qux import quine
            from . import xyz

            var = 'echo "TEST"'

            foo = None
            foo.bar(var)
            """
        )

        linter = get_bad_module_attribute_use_implementation({'foo': ['bar']})
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected 
开发者ID:duo-labs,项目名称:dlint,代码行数:23,代码来源:test_bad_module_attribute_use.py

示例6: test_module_attribute_usage_nested

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_module_attribute_usage_nested(self):
        python_node = self.get_ast_node(
            """
            import foo

            var = 'echo "TEST"'

            foo.bar(var).baz()
            """
        )

        linter = get_bad_module_attribute_use_implementation({'foo': ['bar']})
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=linter._error_tmpl
            )
        ]

        assert result == expected 
开发者ID:duo-labs,项目名称:dlint,代码行数:26,代码来源:test_bad_module_attribute_use.py

示例7: test_kwargs_present_different_module_path

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_kwargs_present_different_module_path(self):
        python_node = self.get_ast_node(
            """
            import foo
            import boo

            boo.bar.baz(kwarg="test")
            """
        )

        linter = get_bad_kwarg_use_implementation(
            [
                {
                    "module_path": "foo.bar.baz",
                    "kwarg_name": "kwarg",
                    "predicate": dlint.tree.kwarg_present,
                },
            ]
        )
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected 
开发者ID:duo-labs,项目名称:dlint,代码行数:27,代码来源:test_bad_kwarg_use.py

示例8: test_kwargs_missing_module_path

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_kwargs_missing_module_path(self):
        python_node = self.get_ast_node(
            """
            import foo

            foo.bar.baz(kwarg="test")
            """
        )

        linter = get_bad_kwarg_use_implementation(
            [
                {
                    "module_path": "foo.bar.baz",
                    "kwarg_name": "kwarg",
                    "predicate": dlint.tree.kwarg_not_present,
                },
            ]
        )
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected 
开发者ID:duo-labs,项目名称:dlint,代码行数:26,代码来源:test_bad_kwarg_use.py

示例9: test_it_does_not_crash_on_attribute_functions

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_it_does_not_crash_on_attribute_functions(flake8dir):
    flake8dir.make_example_py(
        """
        import foo
        bar = foo.baz(x + 1 for x in range(10))
    """
    )
    result = flake8dir.run_flake8()
    assert result.out_lines == []


# C408 
开发者ID:adamchainz,项目名称:flake8-comprehensions,代码行数:14,代码来源:test_flake8_comprehensions.py

示例10: test_simple

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_simple(self):
        pkgname = 'foo'
        dirname_0 = self.create_init(pkgname)
        dirname_1 = self.create_init(pkgname)
        self.create_submodule(dirname_0, pkgname, 'bar', 0)
        self.create_submodule(dirname_1, pkgname, 'baz', 1)
        import foo.bar
        import foo.baz
        # Ensure we read the expected values
        self.assertEqual(foo.bar.value, 0)
        self.assertEqual(foo.baz.value, 1)

        # Ensure the path is set up correctly
        self.assertEqual(sorted(foo.__path__),
                         sorted([os.path.join(dirname_0, pkgname),
                                 os.path.join(dirname_1, pkgname)]))

        # Cleanup
        shutil.rmtree(dirname_0)
        shutil.rmtree(dirname_1)
        del sys.path[0]
        del sys.path[0]
        del sys.modules['foo']
        del sys.modules['foo.bar']
        del sys.modules['foo.baz']


    # Another awful testing hack to be cleaned up once the test_runpy
    # helpers are factored out to a common location 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:31,代码来源:test_pkgutil.py

示例11: test_mixed_namespace

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_mixed_namespace(self):
        pkgname = 'foo'
        dirname_0 = self.create_init(pkgname)
        dirname_1 = self.create_init(pkgname)
        self.create_submodule(dirname_0, pkgname, 'bar', 0)
        # Turn this into a PEP 420 namespace package
        os.unlink(os.path.join(dirname_0, pkgname, '__init__.py'))
        self.create_submodule(dirname_1, pkgname, 'baz', 1)
        import foo.bar
        import foo.baz
        # Ensure we read the expected values
        self.assertEqual(foo.bar.value, 0)
        self.assertEqual(foo.baz.value, 1)

        # Ensure the path is set up correctly
        self.assertEqual(sorted(foo.__path__),
                         sorted([os.path.join(dirname_0, pkgname),
                                 os.path.join(dirname_1, pkgname)]))

        # Cleanup
        shutil.rmtree(dirname_0)
        shutil.rmtree(dirname_1)
        del sys.path[0]
        del sys.path[0]
        del sys.modules['foo']
        del sys.modules['foo.bar']
        del sys.modules['foo.baz']

    # XXX: test .pkg files 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:31,代码来源:test_pkgutil.py

示例12: test_attrAugmentedAssignment

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_attrAugmentedAssignment(self):
        """
        Augmented assignment of attributes is supported.
        We don't care about attr refs.
        """
        self.flakes('''
        foo = None
        foo.bar += foo.baz
        ''') 
开发者ID:PyCQA,项目名称:pyflakes,代码行数:11,代码来源:test_other.py

示例13: test_doubleClosedOver

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_doubleClosedOver(self):
        """
        Don't warn when the assignment is used in an inner function, even if
        that inner function itself is in an inner function.
        """
        self.flakes('''
        def barMaker():
            foo = 5
            def bar():
                def baz():
                    return foo
            return bar
        ''') 
开发者ID:PyCQA,项目名称:pyflakes,代码行数:15,代码来源:test_other.py

示例14: test_ifexp

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_ifexp(self):
        """
        Test C{foo if bar else baz} statements.
        """
        self.flakes("a = 'moo' if True else 'oink'")
        self.flakes("a = foo if True else 'oink'", m.UndefinedName)
        self.flakes("a = 'moo' if True else bar", m.UndefinedName) 
开发者ID:PyCQA,项目名称:pyflakes,代码行数:9,代码来源:test_other.py

示例15: test_withStatementTupleNames

# 需要导入模块: import foo [as 别名]
# 或者: from foo import baz [as 别名]
def test_withStatementTupleNames(self):
        """
        No warnings are emitted for using any of the tuple of names defined by
        a C{with} statement within the suite or afterwards.
        """
        self.flakes('''
        from __future__ import with_statement
        with open('foo') as (bar, baz):
            bar, baz
        bar, baz
        ''') 
开发者ID:PyCQA,项目名称:pyflakes,代码行数:13,代码来源:test_other.py


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