Pytest: Latest version (3.8.0) broke our test suite

Created on 13 Sep 2018  路  9Comments  路  Source: pytest-dev/pytest

Latest 3.8.0 update broke our osBrain test suite:

https://travis-ci.org/opensistemas-hub/osbrain/builds/427931966

We can reproduce this locally. Forcing Tox to use the older 3.7.4 version fixes the issue.

Note that even though many errors are shown in Travis, they all seem to be related to the same FileNotFoundError issue.

regression

All 9 comments

FYI we also tried disabling all the plugins to see if there were any incompatibilities, but the issue still persists.

Here's a minimal reproduction:

pytest osbrain -k 'test_agent_ipc_from_different_folders or test_timer_recursion'

The 'test_agent_ipc_from_different_folders test pollutes global cwd and so any test after that which relies on cwd is broken

It's unclear where the pytest regression here is though if you want a workaround I'd suggest restoring cwd after that test. Perhaps with a fixture like this:

@pytest.fixture
def restore_pwd():
    pwd = os.getcwd()
    yield
    os.chdir(pwd)

the regression is triggered by the new assertion rewriter bailout tooling which peeks at the cwd

the monkeypatch fixture has a utility to change the working directory and restore it

i'd like to note that this regression is a latent bug in your testsuite - it was pure luck it wasnt triggered earlier

yet we have to protect the assertion rewriter against accidential state

Indeed, the cwd does not exist anymore doing the check:

E       |>>>>>>>>Traceback (most recent call last):
E       |   File "<frozen importlib._bootstrap>", line 2158, in _find_spec
E       | AttributeError: 'AssertionRewritingHook' object has no attribute 'find_spec'
E       |
E       | During handling of the above exception, another exception occurred:
E       |
E       | Traceback (most recent call last):
E       |   File "/home/travis/build/opensistemas-hub/osbrain/osbrain/nameserver.py", line 98, in run
E       |     self._daemon = Pyro4.naming.NameServerDaemon(self.host, self.port)
E       |   File "/home/travis/build/opensistemas-hub/osbrain/.tox/py34/lib/python3.4/site-packages/Pyro4/naming.py", line 268, in __init__
E       |     super(NameServerDaemon, self).__init__(host, port, unixsocket, nathost=nathost, natport=natport)
E       |   File "/home/travis/build/opensistemas-hub/osbrain/.tox/py34/lib/python3.4/site-packages/Pyro4/core.py", line 1132, in __init__
E       |     from Pyro4.socketserver.threadpoolserver import SocketServer_Threadpool
E       |   File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
E       |   File "<frozen importlib._bootstrap>", line 2222, in _find_and_load_unlocked
E       |   File "<frozen importlib._bootstrap>", line 2160, in _find_spec
E       |   File "<frozen importlib._bootstrap>", line 2141, in _find_spec_legacy
E       |   File "/home/travis/build/opensistemas-hub/osbrain/.tox/py34/lib/python3.4/site-packages/_pytest/assertion/rewrite.py", line 86, in find_module
E       |     if self._early_rewrite_bailout(name, state):
E       |   File "/home/travis/build/opensistemas-hub/osbrain/.tox/py34/lib/python3.4/site-packages/_pytest/assertion/rewrite.py", line 202, in _early_rewrite_bailout
E       |     fn_pypath = py.path.local(os.path.sep.join(parts))
E       |   File "/home/travis/build/opensistemas-hub/osbrain/.tox/py34/lib/python3.4/site-packages/py/_path/local.py", line 158, in __init__
E       |     self.strpath = abspath(path)
E       |   File "/home/travis/build/opensistemas-hub/osbrain/.tox/py34/lib/python3.4/posixpath.py", line 361, in abspath
E       |     cwd = os.getcwd()
E       | FileNotFoundError: [Errno 2] No such file or directory

Sadly is actually py.path.local creation that fails... it always tries to match against a physical file? I'm surprised.

Well, py.path.**local** is pretty clear about what it should be. 馃構

I'm working on a fix. 馃憤

Thanks @asottile for the triaging done here. 馃憤

Thanks a lot for your help and quick response!

@nicoddemus's https://github.com/opensistemas-hub/osbrain/pull/312 was already merged. :+1::blush:

Glad to help! Let's keep this open until we fix the issue on our side. 馃憤

Was this page helpful?
0 / 5 - 0 ratings