You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vscode-pytest unable to read testIds from temp file, file not created #24406
I'm getting an error running Pytest on an individual test (using the Test Explorer).
It ends up running the entire test suite instead. Here are some more details. Was told to open this after finding a similar issue, but seems unconnected (#24307 (comment)).
Error[vscode-pytest]: unable to read testIds from temp file[Errno 2] No such file or directory: '/tmp/test-ids-e2faf2fe418633dcef80.txt'
I'm trying to run one test but it 'fails to detect the test ID'.
Note that I'm using devcontainers, with Python + Pylance + pytest explorer installed inside.
Also, not sure if relevant: I looked at /tmp/ but can't see any files named like this. I only see files named like python-test-discovery-698debb64df061b8b350.sock
LOGS:
2024-10-31 22:11:25.650 [info] Attempting to use temp directory for test ids file, file name: test-ids-750dd803c28e00398642.txt
env vars: "TEST_RUN_PIPE":"/tmp/python-test-results-59956af0fc8ae043f0d0.sock","RUN_TEST_IDS_PIPE":"/tmp/test-ids-750dd803c28e00398642.txt"}
2024-10-31 22:11:25.658 [info] Running pytest with arguments: /root/.vscode-server/extensions/ms-python.python-2024.16.1-linux-arm64/python_files/vscode_pytest/run_pytest_script.py --rootdir=/code/myproj
2024-10-31 22:11:25.658 [info] > /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2024.16.1-linux-arm64/python_files/vscode_pytest/run_pytest_script.py --rootdir=.
2024-10-31 22:11:25.658 [info] cwd: .
At this point I see this in my test results:
Error[vscode-pytest]: unable to read testIds from temp file[Errno 2] No such file or directory: '/tmp/test-ids-750dd803c28e00398642.txt'
Python logs don't show anything useful after that and I cancel the test runs. I also watch ls /tmp as I clicked on a test run and only saw the -result files appear. No IDs files.
It might be permissions issue with this. We might need to add a check that verifies that the temp file was created. The other thing is not really a file, it is a Unix Domain Socket. I would check permissions first.
Error[vscode-pytest]: unable to read testIds from temp file[Errno 2] No such file or directory: '/var/folders/f5/9qsxm9ds2nd788spvqqq6hf40000gn/T/test-ids-bd662f439a6f58d10bbe.txt'
The directory exists and there are plenty of other vscode related files in there (called something like vscode-git-0b14b03a2b.sock, pyright-98926-9DQScs6SskRz, etc.), so maybe not a permission problem?
Eleanor Boyd (@eleanorjboyd) May be we can check for this on TS side? I think we can do an access check on the location where we create the file, and log if that is failing. Or attempt an alternate location.
Note that I'm running this on a linux container on my mac, not directly on my mac.
I don't think the problem is mac specific. On my mac this works fine, it's just inside the devcontainer vscode instance that this fails! Karthik Nadig (@karthiknadig)
run python tests
a. create env, install pytest
b. write a simple test
def test_xyz():
assert true
c. go to testing panel, select pytest, run tests
3. set log level to verbose
3. check the python logs for something that says Attempting to use temp directory for test ids file
4. check that the temp directory used is XDG_RUNTIME_DIR (if you have this value, otherwise it will use tempdir)
A specific issue with libfaketime is that it will try to re-exec the process, but this will only occur after the temp test ID file has been deleted by the vscode pytest run script.
I've create a PR to mitigate this issue #25540
Activity
eleanorjboyd commentedon Nov 11, 2024
Karthik Nadig (@karthiknadig) any thoughts on why the temp file creation is not working?
karthiknadig commentedon Nov 11, 2024
It might be permissions issue with this. We might need to add a check that verifies that the temp file was created. The other thing is not really a file, it is a Unix Domain Socket. I would check permissions first.
paul-voelker commentedon Dec 10, 2024
For me on macOS 14.6.1 the error looks like this:
Error[vscode-pytest]: unable to read testIds from temp file[Errno 2] No such file or directory: '/var/folders/f5/9qsxm9ds2nd788spvqqq6hf40000gn/T/test-ids-bd662f439a6f58d10bbe.txt'The directory exists and there are plenty of other vscode related files in there (called something like
vscode-git-0b14b03a2b.sock,pyright-98926-9DQScs6SskRz, etc.), so maybe not a permission problem?github-actions commentedon Jan 19, 2025
Hey Eleanor Boyd (@eleanorjboyd), this issue might need further attention.
Rami Awar (@RamiAwar), you can help us out by closing this issue if the problem no longer exists, or adding more information.
eleanorjboyd commentedon Jan 29, 2025
Rami Awar (@RamiAwar) what machine type are you on? Do you know if you have any permissions added by an administration?
RamiAwar commentedon Feb 4, 2025
I'm on a work macbook.
Even on that machine, I don't have a problem with regular VSCode running tests, only the devcontainer-ized version!
karthiknadig commentedon Feb 4, 2025
Eleanor Boyd (@eleanorjboyd) May be we can check for this on TS side? I think we can do an access check on the location where we create the file, and log if that is failing. Or attempt an alternate location.
11 remaining items
RamiAwar commentedon Feb 21, 2025
Note that I'm running this on a linux container on my mac, not directly on my mac.
I don't think the problem is mac specific. On my mac this works fine, it's just inside the devcontainer vscode instance that this fails!
Karthik Nadig (@karthiknadig)
default to XDG_RUNTIME_DIR for mac/linux in temp file for testing com…
eleanorjboyd commentedon Mar 27, 2025
verification steps:
a. create env, install pytest
b. write a simple test
c. go to testing panel, select pytest, run tests
3. set log level to verbose
3. check the python logs for something that says
Attempting to use temp directory for test ids file4. check that the temp directory used is
XDG_RUNTIME_DIR(if you have this value, otherwise it will use tempdir)itaihay commentedon Nov 2, 2025
A specific issue with
libfaketimeis that it will try to re-exec the process, but this will only occur after the temp test ID file has been deleted by the vscode pytest run script.I've create a PR to mitigate this issue #25540
RamiAwar commentedon Nov 2, 2025
That checks out Itai Hay (@itaihay), one of my colleagues managed to suppress libfaketime when running tests, but it's a hassle.
Would be great if someone can review his PR 🙏🏼 the issue is still not fixed for me.
Move pytest test IDs file deletion to finally block (#25540)