Closed as not planned
Description
apiwarn
seems to conflict with the builtin warnings
plugin introduced in pytest 3.1.
Error log:
_________________________ test_assert_within_finally __________________________
def test_assert_within_finally():
excinfo = py.test.raises(ZeroDivisionError, """
try:
1/0
finally:
i = 42
""")
s = excinfo.exconly()
> assert re.search("division.+by zero", s) is not None
E AssertionError: assert None is not None
E + where None = <function search at 0x01F46830>('division.+by zero', 'ZeroDivisionError: float division')
E + where <function search at 0x01F46830> = re.search
code\test_assertion.py:28: AssertionError
___________________________ test_apiwarn_functional ___________________________
recwarn = WarningsRecorder(record=True)
def test_apiwarn_functional(recwarn):
capture = py.io.StdCapture()
py.log._apiwarn("x.y.z", "something", stacklevel=1)
out, err = capture.reset()
py.builtin.print_("out", out)
py.builtin.print_("err", err)
> assert err.find("x.y.z") != -1
E AssertionError: assert -1 != -1
E + where -1 = <built-in method find of unicode object at 0x003EF038>('x.y.z')
E + where <built-in method find of unicode object at 0x003EF038> = ''.find
log\test_warning.py:16: AssertionError
---------------------------- Captured stdout call -----------------------------
out
err
_______________________________ test_stacklevel _______________________________
recwarn = WarningsRecorder(record=True)
def test_stacklevel(recwarn):
def f():
py.log._apiwarn("x", "some", stacklevel=2)
# 3
# 4
capture = py.io.StdCapture()
f()
out, err = capture.reset()
lno = py.code.getrawcode(test_stacklevel).co_firstlineno + 6
warning = str(err)
> assert warning.find(":%s" % lno) != -1
E AssertionError: assert -1 != -1
E + where -1 = <built-in method find of str object at 0x003EF050>((':%s' % 27))
E + where <built-in method find of str object at 0x003EF050> = ''.find
log\test_warning.py:31: AssertionError
____________________ test_stacklevel_initpkg_with_resolve _____________________
testdir = <Testdir local('c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\testdir\\test_stacklevel_initpkg_with_resolve0')>
recwarn = WarningsRecorder(record=True)
def test_stacklevel_initpkg_with_resolve(testdir, recwarn):
testdir.makepyfile(modabc="""
import py
def f():
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()
p.pyimport()
out, err = capture.reset()
warning = str(err)
loc = 'test_stacklevel_initpkg_with_resolve.py:2'
> assert warning.find(loc) != -1
E AssertionError: assert -1 != -1
E + where -1 = <built-in method find of str object at 0x003EF050>('test_stacklevel_initpkg_with_resolve.py:2')
E + where <built-in method find of str object at 0x003EF050> = ''.find
C:\projects\py\testing\log\test_warning.py:53: AssertionError
_____________________ test_stacklevel_initpkg_no_resolve ______________________
recwarn = WarningsRecorder(record=True)
def test_stacklevel_initpkg_no_resolve(recwarn):
def f():
py.log._apiwarn("x", "some", stacklevel="apipkg")
capture = py.io.StdCapture()
f()
out, err = capture.reset()
lno = py.code.getrawcode(test_stacklevel_initpkg_no_resolve).co_firstlineno + 2
warning = str(err)
> assert warning.find(":%s" % lno) != -1
E AssertionError: assert -1 != -1
E + where -1 = <built-in method find of str object at 0x003EF050>((':%s' % 57))
E + where <built-in method find of str object at 0x003EF050> = ''.find
log\test_warning.py:63: AssertionError
________________________________ test_function ________________________________
recwarn = WarningsRecorder(record=True)
def test_function(recwarn):
capture = py.io.StdCapture()
py.log._apiwarn("x.y.z", "something", function=test_function)
out, err = capture.reset()
py.builtin.print_("out", out)
py.builtin.print_("err", err)
> assert err.find("x.y.z") != -1
E AssertionError: assert -1 != -1
E + where -1 = <built-in method find of unicode object at 0x003EF038>('x.y.z')
E + where <built-in method find of unicode object at 0x003EF038> = ''.find
log\test_warning.py:72: AssertionError
---------------------------- Captured stdout call -----------------------------
out
err
Metadata
Metadata
Assignees
Labels
No labels