Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent CI failure: restore_working_directory FileNotFoundError #1361

Closed
simonw opened this issue Jun 5, 2021 · 4 comments
Closed

Intermittent CI failure: restore_working_directory FileNotFoundError #1361

simonw opened this issue Jun 5, 2021 · 4 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Jun 5, 2021

e.g. in https://github.com/simonw/datasette/runs/2754772233 - this is an intermittent error:

__________ ERROR at setup of test_hook_register_routes_render_message __________
[gw0] linux -- Python 3.8.10 /opt/hostedtoolcache/Python/3.8.10/x64/bin/python

tmpdir = local('/tmp/pytest-of-runner/pytest-0/popen-gw0/test_hook_register_routes_rend0')
request = <SubRequest 'restore_working_directory' for <Function test_hook_register_routes_render_message>>

    @pytest.fixture
    def restore_working_directory(tmpdir, request):
>       previous_cwd = os.getcwd()
E       FileNotFoundError: [Errno 2] No such file or directory
@simonw
Copy link
Owner Author

simonw commented Jun 5, 2021

Stack Overflow: https://stackoverflow.com/a/49367679/6083

The answer was that os.chdir() had been set to the deleted directory by accident. The directory was missing, but the error happened (it seems) at the attempt to get it with os.getcwd().

@simonw
Copy link
Owner Author

simonw commented Jun 5, 2021

I'm going to try removing that restore_working_directory fixture entirely.

@simonw
Copy link
Owner Author

simonw commented Jun 5, 2021

That broke things. Here's how pytest-cov fixed a similar issue: pytest-dev/pytest-cov@7ccb178

See also nedbat/coveragepy#881 and pytest-dev/pytest-cov#306 and nedbat/coveragepy#824

@simonw
Copy link
Owner Author

simonw commented Jun 5, 2021

That seems to have fixed it. I'd love to get rid of this restore_working_directory hack entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant