make genscript provide information as to compatibility
(now that argparse is a dependency on python2.6)
This commit is contained in:
parent
7a8134660f
commit
2a7c79dbf5
16
CHANGELOG
16
CHANGELOG
|
@ -1,9 +1,12 @@
|
|||
Changes between 2.3.5 and 2.4.DEV
|
||||
-----------------------------------
|
||||
|
||||
- integrate option tab-completion when argcomplete is used. Thanks
|
||||
Anthon van der Neut for the PR. This also lets pytest use argparse
|
||||
instead of optparse.
|
||||
- integrate tab-completion on options through use of "argcomplete".
|
||||
Thanks Anthon van der Neut for the PR.
|
||||
|
||||
- pytest now uses argparse instead of optparse (thanks Anthon) which
|
||||
means that "argparse" is added as a dependency if installing into python2.6
|
||||
environments or below.
|
||||
|
||||
- SO-17664702: call fixture finalizers even if the fixture function
|
||||
partially failed (finalizers would not always be called before)
|
||||
|
@ -68,6 +71,13 @@ Changes between 2.3.5 and 2.4.DEV
|
|||
|
||||
- better parametrize error messages, thanks Brianna Laugher
|
||||
|
||||
known incompatibilities:
|
||||
|
||||
- if calling --genscript from python2.7 or above, you only get a
|
||||
standalone script which works on python2.7 or above. Use Python2.6
|
||||
to also get a python2.5 compatible version.
|
||||
|
||||
|
||||
Changes between 2.3.4 and 2.3.5
|
||||
-----------------------------------
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
""" generate a single-file self-contained version of py.test """
|
||||
import py
|
||||
import sys
|
||||
|
||||
def find_toplevel(name):
|
||||
for syspath in py.std.sys.path:
|
||||
|
@ -59,11 +60,21 @@ def pytest_addoption(parser):
|
|||
def pytest_cmdline_main(config):
|
||||
genscript = config.getvalue("genscript")
|
||||
if genscript:
|
||||
tw = py.io.TerminalWriter()
|
||||
deps = ['py', '_pytest', 'pytest']
|
||||
if sys.version_info < (2,7):
|
||||
deps.append("argparse")
|
||||
tw.line("generated script will run on python2.5-python3.3++")
|
||||
else:
|
||||
tw.line("WARNING: generated script will not run on python2.6 "
|
||||
"or below due to 'argparse' dependency. Use python2.6 "
|
||||
"to generate a python2.5/6 compatible script", red=True)
|
||||
script = generate_script(
|
||||
'import py; raise SystemExit(py.test.cmdline.main())',
|
||||
['py', '_pytest', 'pytest'],
|
||||
deps,
|
||||
)
|
||||
|
||||
genscript = py.path.local(genscript)
|
||||
genscript.write(script)
|
||||
tw.line("generated pytest standalone script: %s" % genscript,
|
||||
bold=True)
|
||||
return 0
|
||||
|
|
|
@ -13,6 +13,10 @@ class DictImporter(object):
|
|||
self.sources = sources
|
||||
|
||||
def find_module(self, fullname, path=None):
|
||||
if fullname == "argparse" and sys.version_info >= (2,7):
|
||||
# we were generated with <python2.7 (which pulls in argparse)
|
||||
# but we are running now on a stdlib which has it, so use that.
|
||||
return None
|
||||
if fullname in self.sources:
|
||||
return self
|
||||
if fullname + '.__init__' in self.sources:
|
||||
|
|
6
setup.py
6
setup.py
|
@ -8,6 +8,10 @@ except ImportError:
|
|||
|
||||
long_description = open("README.rst").read()
|
||||
def main():
|
||||
install_requires = ["py>=1.4.15"]
|
||||
if sys.version_info < (2,7):
|
||||
install_requires.append("argparse")
|
||||
|
||||
setup(
|
||||
name='pytest',
|
||||
description='py.test: simple powerful testing with Python',
|
||||
|
@ -21,7 +25,7 @@ def main():
|
|||
entry_points= make_entry_points(),
|
||||
cmdclass = {'test': PyTest},
|
||||
# the following should be enabled for release
|
||||
install_requires=['py>=1.4.14'],
|
||||
install_requires=install_requires,
|
||||
classifiers=['Development Status :: 6 - Mature',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
|
|
|
@ -77,6 +77,9 @@ winpymap = {
|
|||
'python2.5': r'C:\Python25\python.exe',
|
||||
'python2.4': r'C:\Python24\python.exe',
|
||||
'python3.1': r'C:\Python31\python.exe',
|
||||
'python3.2': r'C:\Python32\python.exe',
|
||||
'python3.3': r'C:\Python33\python.exe',
|
||||
'python3.4': r'C:\Python34\python.exe',
|
||||
}
|
||||
|
||||
def getexecutable(name, cache={}):
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import pytest
|
||||
import py, os, sys
|
||||
import subprocess
|
||||
|
||||
|
||||
def pytest_funcarg__standalone(request):
|
||||
return request.cached_setup(scope="module",
|
||||
setup=lambda: Standalone(request))
|
||||
@pytest.fixture(scope="module")
|
||||
def standalone(request):
|
||||
return Standalone(request)
|
||||
|
||||
class Standalone:
|
||||
def __init__(self, request):
|
||||
|
@ -20,6 +21,12 @@ class Standalone:
|
|||
return testdir._run(anypython, self.script, *args)
|
||||
|
||||
def test_gen(testdir, anypython, standalone):
|
||||
if sys.version_info >= (2,7):
|
||||
result = testdir._run(anypython, "-c",
|
||||
"import sys;print sys.version_info >=(2,7)")
|
||||
if result.stdout.str() == "False":
|
||||
pytest.skip("genscript called from python2.7 cannot work "
|
||||
"earlier python versions")
|
||||
result = standalone.run(anypython, testdir, '--version')
|
||||
assert result.ret == 0
|
||||
result.stderr.fnmatch_lines([
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from __future__ import with_statement
|
||||
import py, pytest
|
||||
from _pytest import config as parseopt
|
||||
from textwrap import dedent
|
||||
|
@ -44,7 +45,7 @@ class TestParser:
|
|||
res = argument.attrs()
|
||||
assert res['default'] == 42
|
||||
assert res['dest'] == 'abc'
|
||||
|
||||
|
||||
def test_group_add_and_get(self):
|
||||
parser = parseopt.Parser()
|
||||
group = parser.getgroup("hello", description="desc")
|
||||
|
@ -128,7 +129,7 @@ class TestParser:
|
|||
x = parser.addoption("--ultimate-answer", type=int)
|
||||
args = parser.parse(['--ultimate-answer', '42'])
|
||||
assert args.ultimate_answer == 42
|
||||
|
||||
|
||||
def test_parse_defaultgetter(self):
|
||||
def defaultget(option):
|
||||
if not hasattr(option, 'type'):
|
||||
|
|
Loading…
Reference in New Issue