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


Python outcomes.Skipped方法代码示例

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


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

示例1: pytest_make_collect_report

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def pytest_make_collect_report(collector):
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
    longrepr = None
    if not call.excinfo:
        outcome = "passed"
    else:
        from _pytest import nose

        skip_exceptions = (Skipped,) + nose.get_skip_exceptions()
        if call.excinfo.errisinstance(skip_exceptions):
            outcome = "skipped"
            r = collector._repr_failure_py(call.excinfo, "line").reprcrash
            longrepr = (str(r.path), r.lineno, r.message)
        else:
            outcome = "failed"
            errorinfo = collector.repr_failure(call.excinfo)
            if not hasattr(errorinfo, "toterminal"):
                errorinfo = CollectErrorRepr(errorinfo)
            longrepr = errorinfo
    rep = CollectReport(
        collector.nodeid, outcome, longrepr, getattr(call, "result", None)
    )
    rep.call = call  # see collect_one_node
    return rep 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:26,代码来源:runner.py

示例2: test_petab_suite

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def test_petab_suite():
    """Execute all cases from the petab test suite, report performance."""
    n_success = n_skipped = 0
    for case in petabtests.CASES_LIST:
        try:
            execute_case(case)
            n_success += 1
        except Skipped:
            n_skipped += 1
        except Exception as e:
            # run all despite failures
            logger.error(f"Case {case} failed.")
            logger.error(e)

    logger.info(f"{n_success} / {len(petabtests.CASES_LIST)} successful, "
                f"{n_skipped} skipped")
    if n_success + n_skipped != len(petabtests.CASES_LIST):
        sys.exit(1) 
开发者ID:ICB-DCM,项目名称:pyPESTO,代码行数:20,代码来源:test_petab_suite.py

示例3: check_interactive_exception

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def check_interactive_exception(call, report):
    return call.excinfo and not (
        hasattr(report, "wasxfail")
        or call.excinfo.errisinstance(Skipped)
        or call.excinfo.errisinstance(bdb.BdbQuit)
    ) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:8,代码来源:runner.py

示例4: _init_runner_class

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def _init_runner_class():
    import doctest

    class PytestDoctestRunner(doctest.DebugRunner):
        """
        Runner to collect failures.  Note that the out variable in this case is
        a list instead of a stdout-like object
        """

        def __init__(
            self, checker=None, verbose=None, optionflags=0, continue_on_failure=True
        ):
            doctest.DebugRunner.__init__(
                self, checker=checker, verbose=verbose, optionflags=optionflags
            )
            self.continue_on_failure = continue_on_failure

        def report_failure(self, out, test, example, got):
            failure = doctest.DocTestFailure(test, example, got)
            if self.continue_on_failure:
                out.append(failure)
            else:
                raise failure

        def report_unexpected_exception(self, out, test, example, exc_info):
            if isinstance(exc_info[1], Skipped):
                raise exc_info[1]
            failure = doctest.UnexpectedException(test, example, exc_info)
            if self.continue_on_failure:
                out.append(failure)
            else:
                raise failure

    return PytestDoctestRunner 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:36,代码来源:doctest.py

示例5: check_interactive_exception

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def check_interactive_exception(call: "CallInfo", report: BaseReport) -> bool:
    return call.excinfo is not None and not (
        hasattr(report, "wasxfail")
        or call.excinfo.errisinstance(Skipped)
        or call.excinfo.errisinstance(bdb.BdbQuit)
    ) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:8,代码来源:runner.py

示例6: pytest_make_collect_report

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def pytest_make_collect_report(collector: Collector) -> CollectReport:
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
    # TODO: Better typing for longrepr.
    longrepr = None  # type: Optional[Any]
    if not call.excinfo:
        outcome = "passed"  # type: Literal["passed", "skipped", "failed"]
    else:
        skip_exceptions = [Skipped]
        unittest = sys.modules.get("unittest")
        if unittest is not None:
            # Type ignored because unittest is loaded dynamically.
            skip_exceptions.append(unittest.SkipTest)  # type: ignore
        if call.excinfo.errisinstance(tuple(skip_exceptions)):
            outcome = "skipped"
            r_ = collector._repr_failure_py(call.excinfo, "line")
            assert isinstance(r_, ExceptionChainRepr), repr(r_)
            r = r_.reprcrash
            assert r
            longrepr = (str(r.path), r.lineno, r.message)
        else:
            outcome = "failed"
            errorinfo = collector.repr_failure(call.excinfo)
            if not hasattr(errorinfo, "toterminal"):
                errorinfo = CollectErrorRepr(errorinfo)
            longrepr = errorinfo
    result = call.result if not call.excinfo else None
    rep = CollectReport(collector.nodeid, outcome, longrepr, result)
    rep.call = call  # type: ignore # see collect_one_node
    return rep 
开发者ID:pytest-dev,项目名称:pytest,代码行数:31,代码来源:runner.py

示例7: import_plugin

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def import_plugin(self, modname: str, consider_entry_points: bool = False) -> None:
        """
        Imports a plugin with ``modname``. If ``consider_entry_points`` is True, entry point
        names are also considered to find a plugin.
        """
        # most often modname refers to builtin modules, e.g. "pytester",
        # "terminal" or "capture".  Those plugins are registered under their
        # basename for historic purposes but must be imported with the
        # _pytest prefix.
        assert isinstance(modname, str), (
            "module name as text required, got %r" % modname
        )
        if self.is_blocked(modname) or self.get_plugin(modname) is not None:
            return

        importspec = "_pytest." + modname if modname in builtin_plugins else modname
        self.rewrite_hook.mark_rewrite(importspec)

        if consider_entry_points:
            loaded = self.load_setuptools_entrypoints("pytest11", name=modname)
            if loaded:
                return

        try:
            __import__(importspec)
        except ImportError as e:
            raise ImportError(
                'Error importing plugin "{}": {}'.format(modname, str(e.args[0]))
            ).with_traceback(e.__traceback__) from e

        except Skipped as e:
            from _pytest.warnings import _issue_warning_captured

            _issue_warning_captured(
                PytestConfigWarning("skipped plugin {!r}: {}".format(modname, e.msg)),
                self.hook,
                stacklevel=2,
            )
        else:
            mod = sys.modules[importspec]
            self.register(mod, modname) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:43,代码来源:__init__.py

示例8: test_importorskip_local

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def test_importorskip_local(monkeypatch):
    """Test ``importorskip`` run on local machine with non-existent module, which should skip."""
    monkeypatch.delenv("ARVIZ_CI_MACHINE", raising=False)
    with pytest.raises(Skipped):
        importorskip("non-existent-function") 
开发者ID:arviz-devs,项目名称:arviz,代码行数:7,代码来源:test_helpers.py

示例9: pytest_make_collect_report

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def pytest_make_collect_report(collector):
    call = runner.CallInfo.from_call(lambda: list(collector.collect()), 'collect')
    longrepr = None
    if not call.excinfo:
        outcome = "passed"
    else:
        from _pytest import nose
        from _pytest.outcomes import Skipped
        skip_exceptions = (Skipped,) + nose.get_skip_exceptions()
        if call.excinfo.errisinstance(KeyError):
            outcome = "skipped"
            r = collector._repr_failure_py(call.excinfo, "line").reprcrash
            message = "{} not configured in user_opts.py".format(r.message.split()[-1])
            longrepr = (str(r.path), r.lineno, message)
        elif call.excinfo.errisinstance(skip_exceptions):
            outcome = "skipped"
            r = collector._repr_failure_py(call.excinfo, "line").reprcrash
            longrepr = (str(r.path), r.lineno, r.message)
        else:
            outcome = "failed"
            errorinfo = collector.repr_failure(call.excinfo)
            if not hasattr(errorinfo, "toterminal"):
                errorinfo = runner.CollectErrorRepr(errorinfo)
            longrepr = errorinfo
    rep = runner.CollectReport(collector.nodeid, outcome, longrepr, getattr(call, 'result', None))
    rep.call = call  # see collect_one_node
    return rep 
开发者ID:Parsl,项目名称:parsl,代码行数:29,代码来源:conftest.py

示例10: test_load_dataset

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def test_load_dataset(case_name):
    """Test the load dataset function."""

    with pytest.raises(ValueError):
        load_dataset(frames=100)

    for mod_name in _datasets_opt_deps[case_name]:
        pytest.importorskip(mod_name)

    try:
        load_dataset(case=case_name, frames=1)
    except Skipped:
        pass 
开发者ID:pySTEPS,项目名称:pysteps,代码行数:15,代码来源:test_datasets.py

示例11: import_plugin

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def import_plugin(self, modname, consider_entry_points=False):
        """
        Imports a plugin with ``modname``. If ``consider_entry_points`` is True, entry point
        names are also considered to find a plugin.
        """
        # most often modname refers to builtin modules, e.g. "pytester",
        # "terminal" or "capture".  Those plugins are registered under their
        # basename for historic purposes but must be imported with the
        # _pytest prefix.
        assert isinstance(modname, str), (
            "module name as text required, got %r" % modname
        )
        modname = str(modname)
        if self.is_blocked(modname) or self.get_plugin(modname) is not None:
            return

        importspec = "_pytest." + modname if modname in builtin_plugins else modname
        self.rewrite_hook.mark_rewrite(importspec)

        if consider_entry_points:
            loaded = self.load_setuptools_entrypoints("pytest11", name=modname)
            if loaded:
                return

        try:
            __import__(importspec)
        except ImportError as e:
            new_exc_message = 'Error importing plugin "{}": {}'.format(
                modname, str(e.args[0])
            )
            new_exc = ImportError(new_exc_message)
            tb = sys.exc_info()[2]

            raise new_exc.with_traceback(tb)

        except Skipped as e:
            from _pytest.warnings import _issue_warning_captured

            _issue_warning_captured(
                PytestConfigWarning("skipped plugin {!r}: {}".format(modname, e.msg)),
                self.hook,
                stacklevel=1,
            )
        else:
            mod = sys.modules[importspec]
            self.register(mod, modname) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:48,代码来源:__init__.py

示例12: exec_snippet

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def exec_snippet(self, source):

        # Strip out new_frame/end_frame from source
        if "# later" in source:
            raise Skipped(msg="multi-stage snippet, can't comprehend")

        lines = [
            line
            if all([
                "imgui.new_frame()" not in line,
                "imgui.render()" not in line,
                "imgui.end_frame()" not in line,
                "fonts.get_tex_data_as_rgba32()" not in line,
            ]) else ""
            for line in
            source.split('\n')
        ]
        source = "\n".join(lines)

        if (
            "import array" in source
            and sys.version_info < (3, 0)
        ):
            pytest.skip(
                "array.array does not work properly under py27 as memory view"
            )

        code = compile(source, '<str>', 'exec')
        frameinfo = getframeinfo(currentframe())

        imgui.create_context()
        io = imgui.get_io()
        io.delta_time = 1.0 / 60.0
        io.display_size = 300, 300

        # setup default font
        io.fonts.get_tex_data_as_rgba32()
        io.fonts.add_font_default()
        io.fonts.texture_id = 0  # set any texture ID to avoid segfaults

        imgui.new_frame()

        exec_ns = _ns(locals(), globals())

        try:
            exec(code, exec_ns, exec_ns)
        except Exception as err:
            # note: quick and dirty way to annotate sources with error marker
            print_exc()
            lines = source.split('\n')
            lines.insert(sys.exc_info()[2].tb_next.tb_lineno, "^^^")
            self.code = "\n".join(lines)
            imgui.end_frame()
            raise

        imgui.render() 
开发者ID:swistakm,项目名称:pyimgui,代码行数:58,代码来源:conftest.py

示例13: importorskip

# 需要导入模块: from _pytest import outcomes [as 别名]
# 或者: from _pytest.outcomes import Skipped [as 别名]
def importorskip(
    modname: str, minversion: Optional[str] = None, reason: Optional[str] = None
) -> Any:
    """Import and return the requested module ``modname``.

        Doesn't allow skips on CI machine.
        Borrowed and modified from ``pytest.importorskip``.
    :param str modname: the name of the module to import
    :param str minversion: if given, the imported module's ``__version__``
        attribute must be at least this minimal version, otherwise the test is
        still skipped.
    :param str reason: if given, this reason is shown as the message when the
        module cannot be imported.
    :returns: The imported module. This should be assigned to its canonical
        name.
    Example::
        docutils = pytest.importorskip("docutils")
    """
    # ARVIZ_CI_MACHINE is True if tests run on CI, where ARVIZ_CI_MACHINE env variable exists
    ARVIZ_CI_MACHINE = running_on_ci()
    if ARVIZ_CI_MACHINE:
        import warnings

        compile(modname, "", "eval")  # to catch syntaxerrors

        with warnings.catch_warnings():
            # make sure to ignore ImportWarnings that might happen because
            # of existing directories with the same name we're trying to
            # import but without a __init__.py file
            warnings.simplefilter("ignore")
            __import__(modname)
        mod = sys.modules[modname]
        if minversion is None:
            return mod
        verattr = getattr(mod, "__version__", None)
        if minversion is not None:
            if verattr is None or Version(verattr) < Version(minversion):
                raise Skipped(
                    "module %r has __version__ %r, required is: %r"
                    % (modname, verattr, minversion),
                    allow_module_level=True,
                )
        return mod
    else:
        return pytest.importorskip(modname=modname, minversion=minversion, reason=reason) 
开发者ID:arviz-devs,项目名称:arviz,代码行数:47,代码来源:helpers.py


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