本文整理汇总了Python中py.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python py.__version__方法的具体用法?Python py.__version__怎么用?Python py.__version__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py
的用法示例。
在下文中一共展示了py.__version__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pytest_report_header
# 需要导入模块: import py [as 别名]
# 或者: from py 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
示例2: pytest_sessionstart
# 需要导入模块: import py [as 别名]
# 或者: from py 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)
示例3: pytest_report_header
# 需要导入模块: import py [as 别名]
# 或者: from py 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
示例4: pytest_cmdline_parse
# 需要导入模块: import py [as 别名]
# 或者: from py 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)
示例5: showversion
# 需要导入模块: import py [as 别名]
# 或者: from py 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")
示例6: pytest_cmdline_parse
# 需要导入模块: import py [as 别名]
# 或者: from py import __version__ [as 别名]
def pytest_cmdline_parse():
outcome = yield
config = outcome.get_result() # type: Config
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.invocation_params.args,
)
)
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() -> None:
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)
示例7: showversion
# 需要导入模块: import py [as 别名]
# 或者: from py import __version__ [as 别名]
def showversion(config: Config) -> None:
if config.option.version > 1:
sys.stderr.write(
"This is pytest version {}, imported from {}\n".format(
pytest.__version__, pytest.__file__
)
)
plugininfo = getpluginversioninfo(config)
if plugininfo:
for line in plugininfo:
sys.stderr.write(line + "\n")
else:
sys.stderr.write("pytest {}\n".format(pytest.__version__))
示例8: pytest_sessionstart
# 需要导入模块: import py [as 别名]
# 或者: from py import __version__ [as 别名]
def pytest_sessionstart(self, session: "Session") -> None:
self._session = session
self._sessionstarttime = timing.time()
if not self.showheader:
return
self.write_sep("=", "test session starts", bold=True)
verinfo = platform.python_version()
if not self.no_header:
msg = "platform {} -- Python {}".format(sys.platform, verinfo)
pypy_version_info = getattr(sys, "pypy_version_info", None)
if pypy_version_info:
verinfo = ".".join(map(str, pypy_version_info[:3]))
msg += "[pypy-{}-{}]".format(verinfo, 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)
示例9: test_header_trailer_info
# 需要导入模块: import py [as 别名]
# 或者: from py import __version__ [as 别名]
def test_header_trailer_info(self, testdir, request):
testdir.monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
testdir.makepyfile(
"""
def test_passes():
pass
"""
)
result = testdir.runpytest()
verinfo = ".".join(map(str, sys.version_info[:3]))
result.stdout.fnmatch_lines(
[
"*===== test session starts ====*",
"platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
% (
sys.platform,
verinfo,
pytest.__version__,
py.__version__,
pluggy.__version__,
),
"*test_header_trailer_info.py .*",
"=* 1 passed*in *.[0-9][0-9]s *=",
]
)
if request.config.pluginmanager.list_plugin_distinfo():
result.stdout.fnmatch_lines(["plugins: *"])
示例10: test_dist_missing_data
# 需要导入模块: import py [as 别名]
# 或者: from py import __version__ [as 别名]
def test_dist_missing_data(testdir):
"""Test failure when using a worker without pytest-cov installed."""
venv_path = os.path.join(str(testdir.tmpdir), 'venv')
virtualenv.cli_run([venv_path])
if sys.platform == 'win32':
if platform.python_implementation() == "PyPy":
exe = os.path.join(venv_path, 'bin', 'python.exe')
else:
exe = os.path.join(venv_path, 'Scripts', 'python.exe')
else:
exe = os.path.join(venv_path, 'bin', 'python')
subprocess.check_call([
exe,
'-mpip',
'install',
'py==%s' % py.__version__,
'pytest==%s' % pytest.__version__,
'pytest_xdist==%s' % xdist.__version__
])
script = testdir.makepyfile(SCRIPT)
result = testdir.runpytest('-v',
'--assert=plain',
'--cov=%s' % script.dirpath(),
'--cov-report=term-missing',
'--dist=load',
'--tx=popen//python=%s' % exe,
max_worker_restart_0,
script)
result.stdout.fnmatch_lines([
'The following workers failed to return coverage data, ensure that pytest-cov is installed on these workers.'
])
示例11: check_Python24_pytest_requirements
# 需要导入模块: import py [as 别名]
# 或者: from py import __version__ [as 别名]
def check_Python24_pytest_requirements():
"""
Check pytest requirements in the current Python 2.4.x environment.
Installing pytest into a Python 2.4.x environment requires specific py &
pytest package versions. This function checks whether the environment has
such compatible Python environments installed.
Returns a 2-tuple (have_pytest, have_py) indicating whether valid pytest &
py library packages have been detected in the current Python 2.4.x
environment. If the pytest package has not been detected, the py library
package will not be checked and the have_py value will be set to None.
See the module docstring for more detailed information.
"""
assert sys.version_info[:2] == (2, 4)
try:
from pytest import __version__ as pytest_version
except ImportError:
return False, None # no pytest
pv_from = parse_version(_first_supported_pytest_version)
pv_to = parse_version(_first_unsupported_pytest_version_on_Python_24)
if not (pv_from <= parse_version(pytest_version) < pv_to):
return False, None # incompatible pytest version
try:
from py import __version__ as py_version
except ImportError:
return True, False # no py library package
pv_unsupported = parse_version(_first_unsupported_py_version_on_Python_24)
if parse_version(py_version) >= pv_unsupported:
return True, False # incompatible py library package version
return True, True