improve deprecation, start changelog
--HG-- branch : trunk
This commit is contained in:
parent
a4a652af85
commit
f4ec2d1ecd
|
@ -1,3 +1,12 @@
|
|||
Changes between 1.1.1 and 1.1.0
|
||||
=====================================
|
||||
|
||||
- fix a bug with path.check(versioned=True) for svn paths
|
||||
|
||||
- try harder to have deprecation warnings for py.compat.* accesses
|
||||
report a correct location
|
||||
|
||||
|
||||
Changes between 1.1.0 and 1.0.2
|
||||
=====================================
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ dictionary or an import path.
|
|||
|
||||
(c) Holger Krekel and others, 2009
|
||||
"""
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
|
||||
__version__ = version = version or "1.1.x"
|
||||
import py.apipkg
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import py
|
||||
|
||||
py.log._apiwarn("1.1", "py.compat.doctest deprecated, use standard library version.", stacklevel="initpkg")
|
||||
py.log._apiwarn("1.1", "py.compat.doctest deprecated, use standard library version.",
|
||||
stacklevel="apipkg")
|
||||
doctest = py.std.doctest
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import py
|
||||
py.log._apiwarn("1.1", "py.compat.optparse deprecated, use standard library version.", stacklevel="initpkg")
|
||||
py.log._apiwarn("1.1", "py.compat.optparse deprecated, use standard library version.", stacklevel="apipkg")
|
||||
|
||||
optparse = py.std.optparse
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
import py
|
||||
py.log._apiwarn("1.1", "py.compat.subprocess deprecated, use standard library version.", stacklevel="initpkg")
|
||||
py.log._apiwarn("1.1", "py.compat.subprocess deprecated, use standard library version.",
|
||||
stacklevel="apipkg")
|
||||
subprocess = py.std.subprocess
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import py
|
||||
|
||||
py.log._apiwarn("1.1", "py.compat.textwrap deprecated, use standard library version.", stacklevel="initpkg")
|
||||
py.log._apiwarn("1.1", "py.compat.textwrap deprecated, use standard library version.",
|
||||
stacklevel="apipkg")
|
||||
textwrap = py.std.textwrap
|
||||
|
|
|
@ -13,14 +13,18 @@ class Warning(DeprecationWarning):
|
|||
def _apiwarn(startversion, msg, stacklevel=2, function=None):
|
||||
# below is mostly COPIED from python2.4/warnings.py's def warn()
|
||||
# Get context information
|
||||
if stacklevel == "initpkg":
|
||||
frame = sys._getframe(stacklevel == "initpkg" and 1 or stacklevel)
|
||||
level = 2
|
||||
if isinstance(stacklevel, str):
|
||||
frame = sys._getframe(1)
|
||||
level = 1
|
||||
found = frame.f_code.co_filename.find(stacklevel) != -1
|
||||
while frame:
|
||||
co = frame.f_code
|
||||
if co.co_name == "__getattr__" and co.co_filename.find("initpkg") !=-1:
|
||||
stacklevel = level
|
||||
break
|
||||
if co.co_filename.find(stacklevel) == -1:
|
||||
if found:
|
||||
stacklevel = level
|
||||
break
|
||||
else:
|
||||
found = True
|
||||
level += 1
|
||||
frame = frame.f_back
|
||||
else:
|
||||
|
|
2
setup.py
2
setup.py
|
@ -28,7 +28,7 @@ def main():
|
|||
name='py',
|
||||
description='py.test and pylib: rapid testing and development utils.',
|
||||
long_description = long_description,
|
||||
version= trunk or '1.1.0',
|
||||
version= trunk or '1.1.1',
|
||||
url='http://pylib.org',
|
||||
license='MIT license',
|
||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||
|
|
|
@ -28,23 +28,30 @@ def test_stacklevel():
|
|||
assert warning.find(":%s" % lno) != -1
|
||||
|
||||
def test_stacklevel_initpkg_with_resolve(testdir):
|
||||
mod = testdir.makepyfile(initpkg="""
|
||||
testdir.makepyfile(modabc="""
|
||||
import py
|
||||
def __getattr__():
|
||||
f()
|
||||
def f():
|
||||
py.log._apiwarn("x", "some", stacklevel="initpkg")
|
||||
""").pyimport()
|
||||
py.log._apiwarn("x", "some", stacklevel="apipkg123")
|
||||
""")
|
||||
testdir.makepyfile(apipkg123="""
|
||||
def __getattr__():
|
||||
import modabc
|
||||
modabc.f()
|
||||
""")
|
||||
p = testdir.makepyfile("""
|
||||
import apipkg123
|
||||
apipkg123.__getattr__()
|
||||
""")
|
||||
capture = py.io.StdCapture()
|
||||
mod.__getattr__()
|
||||
p.pyimport()
|
||||
out, err = capture.reset()
|
||||
lno = py.code.getrawcode(test_stacklevel_initpkg_with_resolve).co_firstlineno + 9
|
||||
warning = str(err)
|
||||
assert warning.find(":%s" % lno) != -1
|
||||
loc = 'test_stacklevel_initpkg_with_resolve.py:2'
|
||||
assert warning.find(loc) != -1
|
||||
|
||||
def test_stacklevel_initpkg_no_resolve():
|
||||
def f():
|
||||
py.log._apiwarn("x", "some", stacklevel="initpkg")
|
||||
py.log._apiwarn("x", "some", stacklevel="apipkg")
|
||||
capture = py.io.StdCapture()
|
||||
f()
|
||||
out, err = capture.reset()
|
||||
|
|
|
@ -147,6 +147,6 @@ class TestDistribution:
|
|||
args += ["--tx", "popen//python=%s" % interpreters[0]]
|
||||
args += ["--tx", "popen//python=%s" % interpreters[1]]
|
||||
result = testdir.runpytest(*args)
|
||||
result.stdout.fnmatch_lines(["2...4"])
|
||||
result.stdout.fnmatch_lines(["2...5"])
|
||||
|
||||
s = result.stdout.str()
|
||||
assert "2.4" in s
|
||||
assert "2.5" in s
|
||||
|
|
|
@ -7,9 +7,10 @@ def test_functional_deprecation(testdir):
|
|||
check(recwarn, name)
|
||||
def check(recwarn, name):
|
||||
x = getattr(py.compat, name)
|
||||
recwarn.pop(DeprecationWarning)
|
||||
warn = recwarn.pop(DeprecationWarning)
|
||||
recwarn.clear()
|
||||
assert x == getattr(py.std, name)
|
||||
assert warn.filename.find("test_functional_deprecation.py") != -1
|
||||
""")
|
||||
result = testdir.runpytest()
|
||||
assert result.ret == 0
|
||||
|
|
Loading…
Reference in New Issue