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


Python pytest.__version__方法代码示例

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


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

示例1: pytest_report_header

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def pytest_report_header(config):
    lines = []
    if config.option.debug or config.option.traceconfig:
        lines.append(
            "using: pytest-{} pylib-{}".format(pytest.__version__, py.__version__)
        )

        verinfo = getpluginversioninfo(config)
        if verinfo:
            lines.extend(verinfo)

    if config.option.traceconfig:
        lines.append("active plugins:")
        items = config.pluginmanager.list_name_plugin()
        for name, plugin in items:
            if hasattr(plugin, "__file__"):
                r = plugin.__file__
            else:
                r = repr(plugin)
            lines.append("    {:<20}: {}".format(name, r))
    return lines 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:23,代码来源:helpconfig.py

示例2: pytest_sessionstart

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def pytest_sessionstart(self, session):
        self._session = session
        self._sessionstarttime = time.time()
        if not self.showheader:
            return
        self.write_sep("=", "test session starts", bold=True)
        verinfo = platform.python_version()
        msg = "platform {} -- Python {}".format(sys.platform, verinfo)
        if hasattr(sys, "pypy_version_info"):
            verinfo = ".".join(map(str, sys.pypy_version_info[:3]))
            msg += "[pypy-{}-{}]".format(verinfo, sys.pypy_version_info[3])
        msg += ", pytest-{}, py-{}, pluggy-{}".format(
            pytest.__version__, py.__version__, pluggy.__version__
        )
        if (
            self.verbosity > 0
            or self.config.option.debug
            or getattr(self.config.option, "pastebin", None)
        ):
            msg += " -- " + str(sys.executable)
        self.write_line(msg)
        lines = self.config.hook.pytest_report_header(
            config=self.config, startdir=self.startdir
        )
        self._write_report_lines_from_hooks(lines) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:27,代码来源:terminal.py

示例3: to_list

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def to_list(self):
        """
        Converts self to a list to get all fixture names, and caches the result.
        :return:
        """
        if self._as_list is None:
            # crawl the tree to get the list of unique fixture names
            fixturenames_closure = self._to_list()

            if LooseVersion(pytest.__version__) >= LooseVersion('3.5.0'):
                # sort by scope
                def sort_by_scope(arg_name):
                    try:
                        fixturedefs = self.get_all_fixture_defs()[arg_name]
                    except KeyError:
                        return get_pytest_function_scopenum()
                    else:
                        return fixturedefs[-1].scopenum
                fixturenames_closure.sort(key=sort_by_scope)

            self._as_list = fixturenames_closure

        return self._as_list 
开发者ID:smarie,项目名称:python-pytest-cases,代码行数:25,代码来源:plugin.py

示例4: pytest_report_header

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def pytest_report_header(config: Config) -> List[str]:
    lines = []
    if config.option.debug or config.option.traceconfig:
        lines.append(
            "using: pytest-{} pylib-{}".format(pytest.__version__, py.__version__)
        )

        verinfo = getpluginversioninfo(config)
        if verinfo:
            lines.extend(verinfo)

    if config.option.traceconfig:
        lines.append("active plugins:")
        items = config.pluginmanager.list_name_plugin()
        for name, plugin in items:
            if hasattr(plugin, "__file__"):
                r = plugin.__file__
            else:
                r = repr(plugin)
            lines.append("    {:<20}: {}".format(name, r))
    return lines 
开发者ID:pytest-dev,项目名称:pytest,代码行数:23,代码来源:helpconfig.py

示例5: _checkversion

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def _checkversion(self) -> None:
        import pytest

        minver = self.inicfg.get("minversion", None)
        if minver:
            # Imported lazily to improve start-up time.
            from packaging.version import Version

            if not isinstance(minver, str):
                raise pytest.UsageError(
                    "%s: 'minversion' must be a single value" % self.inifile
                )

            if Version(minver) > Version(pytest.__version__):
                raise pytest.UsageError(
                    "%s: 'minversion' requires pytest-%s, actual pytest-%s'"
                    % (self.inifile, minver, pytest.__version__,)
                ) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:20,代码来源:__init__.py

示例6: test_no_header_trailer_info

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def test_no_header_trailer_info(self, testdir, request):
        testdir.monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
        testdir.makepyfile(
            """
            def test_passes():
                pass
        """
        )
        result = testdir.runpytest("--no-header")
        verinfo = ".".join(map(str, sys.version_info[:3]))
        result.stdout.no_fnmatch_line(
            "platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
            % (
                sys.platform,
                verinfo,
                pytest.__version__,
                py.__version__,
                pluggy.__version__,
            )
        )
        if request.config.pluginmanager.list_plugin_distinfo():
            result.stdout.no_fnmatch_line("plugins: *") 
开发者ID:pytest-dev,项目名称:pytest,代码行数:24,代码来源:test_terminal.py

示例7: test_cached_pyc_includes_pytest_version

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def test_cached_pyc_includes_pytest_version(self, testdir, monkeypatch):
        """Avoid stale caches (#1671)"""
        monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", raising=False)
        testdir.makepyfile(
            test_foo="""
            def test_foo():
                assert True
            """
        )
        result = testdir.runpytest_subprocess()
        assert result.ret == 0
        found_names = glob.glob(
            "__pycache__/*-pytest-{}.pyc".format(pytest.__version__)
        )
        assert found_names, "pyc with expected tag not found in names: {}".format(
            glob.glob("__pycache__/*.pyc")
        ) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:19,代码来源:test_assertrewrite.py

示例8: check

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def check(self):
        super().check()

        msgs = []
        msg_template = ('{package} is required to run the Matplotlib test '
                        'suite. Please install it with pip or your preferred '
                        'tool to run the test suite')

        bad_pytest = msg_template.format(
            package='pytest %s or later' % self.pytest_min_version
        )
        try:
            import pytest
            if is_min_version(pytest.__version__, self.pytest_min_version):
                msgs += ['using pytest version %s' % pytest.__version__]
            else:
                msgs += [bad_pytest]
        except ImportError:
            msgs += [bad_pytest]

        return ' / '.join(msgs) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:23,代码来源:setupext.py

示例9: get_versions

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def get_versions(self):
        """Return versions of framework and its plugins."""
        import pytest
        versions = ['pytest {}'.format(pytest.__version__)]

        class GetPluginVersionsPlugin():
            def pytest_cmdline_main(self, config):
                nonlocal versions
                plugininfo = config.pluginmanager.list_plugin_distinfo()
                if plugininfo:
                    for plugin, dist in plugininfo:
                        versions.append("   {} {}".format(dist.project_name,
                                                          dist.version))

        # --capture=sys needed on Windows to avoid
        # ValueError: saved filedescriptor not valid anymore
        pytest.main(['-V', '--capture=sys'],
                    plugins=[GetPluginVersionsPlugin()])
        return versions 
开发者ID:spyder-ide,项目名称:spyder-unittest,代码行数:21,代码来源:pytestrunner.py

示例10: skip

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def skip(reason):
    if pytest.__version__ >= '3':
        raise pytest.skip.Exception(reason, allow_module_level=True)
    else:
        pytest.skip(reason) 
开发者ID:probcomp,项目名称:cgpm,代码行数:7,代码来源:hacks.py

示例11: test_generate_empty_html

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def test_generate_empty_html(self):
        """ Ensures the application is still rendered gracefully """
        self.app.config['ARA_IGNORE_EMPTY_GENERATION'] = False
        dir = self.generate_dir
        shell = ara.shell.AraCli()
        shell.prepare_to_run_command(ara.cli.generate.GenerateHtml)
        cmd = ara.cli.generate.GenerateHtml(shell, None)
        parser = cmd.get_parser('test')
        args = parser.parse_args([dir])

        with pytest.warns(MissingURLGeneratorWarning) as warnings:
            cmd.take_action(args)

        # pytest 3.0 through 3.1 are backwards incompatible here
        if LooseVersion(pytest.__version__) >= LooseVersion('3.1.0'):
            cat = [item._category_name for item in warnings]
            self.assertTrue(any('MissingURLGeneratorWarning' in c
                                for c in cat))
        else:
            self.assertTrue(any(MissingURLGeneratorWarning == w.category
                                for w in warnings))

        paths = [
            os.path.join(dir, 'index.html'),
            os.path.join(dir, 'static'),
        ]

        for path in paths:
            self.assertTrue(os.path.exists(path)) 
开发者ID:dmsimard,项目名称:ara-archive,代码行数:31,代码来源:test_cli.py

示例12: pytest_cmdline_parse

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def pytest_cmdline_parse():
    outcome = yield
    config = outcome.get_result()
    if config.option.debug:
        path = os.path.abspath("pytestdebug.log")
        debugfile = open(path, "w")
        debugfile.write(
            "versions pytest-%s, py-%s, "
            "python-%s\ncwd=%s\nargs=%s\n\n"
            % (
                pytest.__version__,
                py.__version__,
                ".".join(map(str, sys.version_info)),
                os.getcwd(),
                config._origargs,
            )
        )
        config.trace.root.setwriter(debugfile.write)
        undo_tracing = config.pluginmanager.enable_tracing()
        sys.stderr.write("writing pytestdebug information to %s\n" % path)

        def unset_tracing():
            debugfile.close()
            sys.stderr.write("wrote pytestdebug information to %s\n" % debugfile.name)
            config.trace.root.setwriter(None)
            undo_tracing()

        config.add_cleanup(unset_tracing) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:30,代码来源:helpconfig.py

示例13: showversion

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def showversion(config):
    p = py.path.local(pytest.__file__)
    sys.stderr.write(
        "This is pytest version {}, imported from {}\n".format(pytest.__version__, p)
    )
    plugininfo = getpluginversioninfo(config)
    if plugininfo:
        for line in plugininfo:
            sys.stderr.write(line + "\n") 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:11,代码来源:helpconfig.py

示例14: _checkversion

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def _checkversion(self):
        import pytest

        minver = self.inicfg.get("minversion", None)
        if minver:
            if Version(minver) > Version(pytest.__version__):
                raise pytest.UsageError(
                    "%s:%d: requires pytest-%s, actual pytest-%s'"
                    % (
                        self.inicfg.config.path,
                        self.inicfg.lineof("minversion"),
                        minver,
                        pytest.__version__,
                    )
                ) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:17,代码来源:__init__.py

示例15: test_synthesis

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import __version__ [as 别名]
def test_synthesis(module_results_dct):
    if LooseVersion(pytest.__version__) < LooseVersion('3.0.0'):
        # the way to make ids uniques in case of duplicates was different in old pytest
        assert list(module_results_dct) == ['test_foo[0u_is_a]', 'test_foo[1u_is_a]']
    else:
        assert list(module_results_dct) == ['test_foo[u_is_a0]', 'test_foo[u_is_a1]'] 
开发者ID:smarie,项目名称:python-pytest-cases,代码行数:8,代码来源:test_issue_fixture_union1.py


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