Yeah, I know this isn’t really the right place for this, but there’s a real question here that the audience might have some insight into.
Recently, VS Code seems to be installing itself as the program to run .py programs, and I can’t for the life of me find out where this is set. I can’t be more precise as to “recently”, but it may have been when the switch to pylance happened, I don’t think I recall it happening with the earlier language server.
I work on a project which has a large testsuite and a small number of the tests are now failing because instead of being run by Python, they pop up an instance of VS Code with the test script in the editor window. All five tests have in common that there’s a python script that mocks an executable. In the entire rest of the testsuite this is wrapped so as to not cause problems, in other words something like _python_ mock_cc.py ...
where _python_
is the carefully obtained name of the current interpreter and all works fine. But for these tests, they are exercising a feature that hashes of executed command lines are cached for future comparisons (it’s a build tool) so it has to be the exact command line to be able to perform the tests, it can’t be fudged.
So the two-part question: is it reasonable for an IDE to install itself as the default program to run .py files on Windows (that’s the piece I’m using to tenuously link this post to the intent of this channel :-), and if so, how can a program (meaning: our test harness) detect that this is the case so we can skip tests that would effectively “hang” in this event? This isn’t a problem for our CI as we can ensure that “grabbers” aren’t part of the provisioning, but it’s still irritating for developer workstations. The settings applet “Choose default apps by file type” does clearly show Visual Studio Code as the default for .py and .pyi files, but I have no clue how to detect this programmatically.