Fix errors related to warnings raised by xdist
- pytester was creating a 'pexpect' directory to serve as temporary dir, but due to the fact that xdist adds the current directory to sys.path, that directory was being considered as candidate for import as a package. The directory is empty and a warning was being raised about it missing __init__ file, which is now turned into an error by our filterwarnings config in pytest.ini. - Decided to play it safe and ignore any warnings during `pytest.importorskip`. - pytest-xdist and execnet raise two warnings which should be fixed upstream: pytest-dev/pytest-xdist/issues/133
This commit is contained in:
parent
916d272c44
commit
2c730743f1
|
@ -1008,7 +1008,7 @@ class Testdir(object):
|
|||
The pexpect child is returned.
|
||||
|
||||
"""
|
||||
basetemp = self.tmpdir.mkdir("pexpect")
|
||||
basetemp = self.tmpdir.mkdir("temp-pexpect")
|
||||
invoke = " ".join(map(str, self._getpytestargs()))
|
||||
cmd = "%s --basetemp=%s %s" % (invoke, basetemp, string)
|
||||
return self.spawn(cmd, expect_timeout=expect_timeout)
|
||||
|
|
|
@ -554,14 +554,21 @@ def importorskip(modname, minversion=None):
|
|||
__version__ attribute. If no minversion is specified the a skip
|
||||
is only triggered if the module can not be imported.
|
||||
"""
|
||||
import warnings
|
||||
__tracebackhide__ = True
|
||||
compile(modname, '', 'eval') # to catch syntaxerrors
|
||||
should_skip = False
|
||||
try:
|
||||
__import__(modname)
|
||||
except ImportError:
|
||||
# Do not raise chained exception here(#1485)
|
||||
should_skip = True
|
||||
|
||||
with warnings.catch_warnings():
|
||||
# make sure to ignore ImportWarnings that might happen because
|
||||
# of existing directories with the same name we're trying to
|
||||
# import but without a __init__.py file
|
||||
warnings.simplefilter('ignore')
|
||||
try:
|
||||
__import__(modname)
|
||||
except ImportError:
|
||||
# Do not raise chained exception here(#1485)
|
||||
should_skip = True
|
||||
if should_skip:
|
||||
raise Skipped("could not import %r" %(modname,), allow_module_level=True)
|
||||
mod = sys.modules[modname]
|
||||
|
|
4
tox.ini
4
tox.ini
|
@ -181,6 +181,10 @@ filterwarnings= error
|
|||
ignore:bad escape.*:DeprecationWarning:re
|
||||
# produced by path.readlines
|
||||
ignore:.*U.*mode is deprecated:DeprecationWarning
|
||||
# produced by pytest-xdist
|
||||
ignore:.*type argument to addoption.*:DeprecationWarning
|
||||
# produced by python >=3.5 on execnet (pytest-xdist)
|
||||
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*: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