Skip to content

Running pytest within pytest fails with pytest==8.0.0rc1 #11807

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

Closed
mwouts opened this issue Jan 12, 2024 · 3 comments
Closed

Running pytest within pytest fails with pytest==8.0.0rc1 #11807

mwouts opened this issue Jan 12, 2024 · 3 comments

Comments

@mwouts
Copy link

mwouts commented Jan 12, 2024

Thanks for maintaining and developing pytest. This is such an amazing tool!

I have setup a --pre version of the CI on one of the projects that I maintain, and it happens that one test fails with the release candidate pytest==8.0.0rc1.

Here are the logs of the action: https://github.com/mwouts/jupytext/actions/runs/7487800603/job/20381150371

The failing test does the following:

  • It creates a temporary .py file from a Markdown document
  • And then it calls pytest on that .py file, so in the end it's calling pytest /tmp/notebook_lx_y64ur.py.

With pytest==8.0.0rc1, the test fails with the following error:

E   PermissionError: [Errno 13] Permission denied: '/tmp/snap-private-tmp/__init__.py'

I am not sure how to extract a simpler minimal example from this, but I can look into this if you think that would help. Thanks!

@RonnyPfannschmidt
Copy link
Member

duplicate of #11781

@RonnyPfannschmidt RonnyPfannschmidt closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
@bluetech
Copy link
Member

Yes, as written in the other issue, you should avoid running things from /tmp; the way pytest works requires looking inside & running things from the directory (like conftest.py, __init__.py) and since /tmp is world-writable you really don't want that. It's better to put the file inside tmp_path or even just in a tempfile.TemporaryDirectory, but not directly in /tmp.

@mwouts
Copy link
Author

mwouts commented Jan 13, 2024

Yes, as written in the other issue, you should avoid running things from /tmp; the way pytest works requires looking inside & running things from the directory (like conftest.py, __init__.py) and since /tmp is world-writable you really don't want that. It's better to put the file inside tmp_path or even just in a tempfile.TemporaryDirectory, but not directly in /tmp.

Oh thanks for pointing this out! Sure I should be able to use tempfile.TemporaryDirectory, that's a great suggestion!

fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
fabianp added a commit to fabianp/optax that referenced this issue Jan 29, 2024
This solves the issue of pytest 8.0.0 not being able to run
tests from /tmp/ directory.

See pytest-dev/pytest#11807
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants