當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。