Clean up warnings generated by pytest's own suite
This commit is contained in:
parent
d027f760c0
commit
fa56114115
|
@ -936,7 +936,7 @@ def _idval(val, argname, idx, idfn, config=None):
|
|||
import warnings
|
||||
msg = "Raised while trying to determine id of parameter %s at position %d." % (argname, idx)
|
||||
msg += '\nUpdate your code as this will raise an error in pytest-4.0.'
|
||||
warnings.warn(msg)
|
||||
warnings.warn(msg, DeprecationWarning)
|
||||
if s:
|
||||
return _escape_strings(s)
|
||||
|
||||
|
|
|
@ -339,10 +339,16 @@ class TestGeneralUsage(object):
|
|||
"*ERROR*test_b.py::b*",
|
||||
])
|
||||
|
||||
@pytest.mark.usefixtures('recwarn')
|
||||
def test_namespace_import_doesnt_confuse_import_hook(self, testdir):
|
||||
# Ref #383. Python 3.3's namespace package messed with our import hooks
|
||||
# Importing a module that didn't exist, even if the ImportError was
|
||||
# gracefully handled, would make our test crash.
|
||||
"""
|
||||
Ref #383. Python 3.3's namespace package messed with our import hooks
|
||||
Importing a module that didn't exist, even if the ImportError was
|
||||
gracefully handled, would make our test crash.
|
||||
|
||||
Use recwarn here to silence this warning in Python 2.6 and 2.7:
|
||||
ImportWarning: Not importing directory '...\not_a_package': missing __init__.py
|
||||
"""
|
||||
testdir.mkdir('not_a_package')
|
||||
p = testdir.makepyfile("""
|
||||
try:
|
||||
|
|
|
@ -545,9 +545,21 @@ class TestRequestBasic(object):
|
|||
return l.pop()
|
||||
def test_func(something): pass
|
||||
""")
|
||||
import contextlib
|
||||
if getfixmethod == 'getfuncargvalue':
|
||||
warning_expectation = pytest.warns(DeprecationWarning)
|
||||
else:
|
||||
# see #1830 for a cleaner way to accomplish this
|
||||
@contextlib.contextmanager
|
||||
def expecting_no_warning(): yield
|
||||
|
||||
warning_expectation = expecting_no_warning()
|
||||
|
||||
req = item._request
|
||||
with warning_expectation:
|
||||
fixture_fetcher = getattr(req, getfixmethod)
|
||||
pytest.raises(FixtureLookupError, fixture_fetcher, "notexists")
|
||||
with pytest.raises(FixtureLookupError):
|
||||
fixture_fetcher("notexists")
|
||||
val = fixture_fetcher("something")
|
||||
assert val == 1
|
||||
val = fixture_fetcher("something")
|
||||
|
@ -560,7 +572,6 @@ class TestRequestBasic(object):
|
|||
assert item.funcargs["something"] == 1
|
||||
assert len(get_public_names(item.funcargs)) == 2
|
||||
assert "request" in item.funcargs
|
||||
#assert item.funcargs == {'something': 1, "other": 2}
|
||||
|
||||
def test_request_addfinalizer(self, testdir):
|
||||
item = testdir.getitem("""
|
||||
|
|
|
@ -347,6 +347,7 @@ class TestMetafunc(object):
|
|||
def test_foo(arg):
|
||||
pass
|
||||
""")
|
||||
with pytest.warns(DeprecationWarning):
|
||||
result = testdir.runpytest("--collect-only")
|
||||
result.stdout.fnmatch_lines([
|
||||
"<Module 'test_parametrize_ids_exception.py'>",
|
||||
|
|
|
@ -141,7 +141,7 @@ class TestConfigAPI(object):
|
|||
from __future__ import unicode_literals
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption('--hello', type='string')
|
||||
parser.addoption('--hello', type=str)
|
||||
""")
|
||||
config = testdir.parseconfig('--hello=this')
|
||||
assert config.getoption('hello') == 'this'
|
||||
|
|
|
@ -34,15 +34,16 @@ class TestParser(object):
|
|||
)
|
||||
|
||||
def test_argument_type(self):
|
||||
argument = parseopt.Argument('-t', dest='abc', type='int')
|
||||
argument = parseopt.Argument('-t', dest='abc', type=int)
|
||||
assert argument.type is int
|
||||
argument = parseopt.Argument('-t', dest='abc', type='string')
|
||||
argument = parseopt.Argument('-t', dest='abc', type=str)
|
||||
assert argument.type is str
|
||||
argument = parseopt.Argument('-t', dest='abc', type=float)
|
||||
assert argument.type is float
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.raises(KeyError):
|
||||
argument = parseopt.Argument('-t', dest='abc', type='choice')
|
||||
argument = parseopt.Argument('-t', dest='abc', type='choice',
|
||||
argument = parseopt.Argument('-t', dest='abc', type=str,
|
||||
choices=['red', 'blue'])
|
||||
assert argument.type is str
|
||||
|
||||
|
@ -176,8 +177,8 @@ class TestParser(object):
|
|||
elif option.type is str:
|
||||
option.default = "world"
|
||||
parser = parseopt.Parser(processopt=defaultget)
|
||||
parser.addoption("--this", dest="this", type="int", action="store")
|
||||
parser.addoption("--hello", dest="hello", type="string", action="store")
|
||||
parser.addoption("--this", dest="this", type=int, action="store")
|
||||
parser.addoption("--hello", dest="hello", type=str, action="store")
|
||||
parser.addoption("--no", dest="no", action="store_true")
|
||||
option = parser.parse([])
|
||||
assert option.hello == "world"
|
||||
|
|
6
tox.ini
6
tox.ini
|
@ -176,7 +176,11 @@ python_files=test_*.py *_test.py testing/*/*.py
|
|||
python_classes=Test Acceptance
|
||||
python_functions=test
|
||||
norecursedirs = .tox ja .hg cx_freeze_source
|
||||
|
||||
filterwarnings= error
|
||||
# produced by path.local
|
||||
ignore:bad escape.*:DeprecationWarning:re
|
||||
# produced by path.readlines
|
||||
ignore:.*U.*mode is deprecated:DeprecationWarning
|
||||
|
||||
[flake8]
|
||||
ignore =E401,E225,E261,E128,E124,E301,E302,E121,E303,W391,E501,E231,E126,E701,E265,E241,E251,E226,E101,W191,E131,E203,E122,E123,E271,E712,E222,E127,E125,E221,W292,E111,E113,E293,E262,W293,E129,E702,E201,E272,E202,E704,E731,E402
|
||||
|
|
Loading…
Reference in New Issue