Skip to content

vscode-pytest unable to read testIds from temp file, file not created #24406

Description

@RamiAwar

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.

Activity

  1. eleanorjboyd commented on Nov 11, 2024

    @eleanorjboyd
    Member

    Karthik Nadig (@karthiknadig) any thoughts on why the temp file creation is not working?

  2. karthiknadig commented on Nov 11, 2024

    @karthiknadig
    Member

    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.

  3. paul-voelker commented on Dec 10, 2024

    @paul-voelker

    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?

  4. github-actions commented on Jan 19, 2025

    @github-actions

    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.

  5. added
    needs spikeLabel for issues that need investigation before they can be worked on.
    and removed
    info-neededIssue requires more information from poster
    triage-neededNeeds assignment to the proper sub-team
    on Jan 19, 2025
  6. eleanorjboyd commented on Jan 29, 2025

    @eleanorjboyd
    Member

    Rami Awar (@RamiAwar) what machine type are you on? Do you know if you have any permissions added by an administration?

  7. RamiAwar commented on Feb 4, 2025

    @RamiAwar
    Author

    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!

  8. karthiknadig commented on Feb 4, 2025

    @karthiknadig
    Member

    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.

  9. 11 remaining items

  10. RamiAwar commented on Feb 21, 2025

    @RamiAwar
    Author

    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)

  11. eleanorjboyd commented on Mar 27, 2025

    @eleanorjboyd
    Member

    verification steps:

    1. on mac / linux
    2. 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)

  12. itaihay commented on Nov 2, 2025

    @itaihay

    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

  13. RamiAwar commented on Nov 2, 2025

    @RamiAwar
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions