Repository navigation
Running "tests/runtests.py" on Windows #13936
Copy link
Copy link
Closed
Labels
project: infrastructuretypeshed build, test, or distribution relatedtypeshed build, test, or distribution related
Description
(.venv) C:\clones\typeshed>tests\runtests -h
usage: runtests.py [-h] [--run-stubtest] [--python-version {3.9,3.10,3.11,3.12,3.13}] path
positional arguments:
path Path of the stub to test in format <folder>/<stub>, from the root of the project.
...
(.venv) C:\clones\typeshed>tests\runtests.py /clones/typeshed/stdlib/ast.pyi
usage: runtests.py [-h] [--run-stubtest] [--python-version {3.9,3.10,3.11,3.12,3.13}] path
runtests.py: error: 'path' argument should be in format <folder>/<stub>.
Oh, oops!
(.venv) C:\clones\typeshed>tests\runtests.py stdlib/ast.pyi
...
--- TEST SUMMARY: One or more tests failed. See above for details. ---
pre-commit Success
Check structure: Success
Pyright: Success
mypy: Success
stubtest: Success
pytype: Failed
Pyright regression tests: Success
mypy regression test: SuccessI troubleshoot for at least two hours, including reinstalling venv and installing editable ts_utils.
# to typeshed. Installing ts_utils editable would solve that, seeNow, pytype passes if I run it directly.
(.venv) C:\clones\typeshed\tests>pytype_test.py --print-stderr --typeshed-location /clones/typeshed \clones\typeshed\stdlib\ast.pyi
Testing files with pytype...
Ran pytype with 1 pyis, got 0 errors.
The solution
After another 30 minutes, I am able to get:
(.venv) C:\clones\typeshed>tests\runtests.py stdlib\ast.pyi
...
--- TEST SUMMARY: All tests passed! ---
pre-commit Success
Check structure: Success
Pyright: Success
mypy: Success
stubtest: Success
pytype: Success
Pyright regression tests: Success
mypy regression test: SuccessThat was the solution. I didn't need to spend all that time troubleshooting and reinstalling.
from pathlib import PurePath
print(f"...in format {PurePath('<folder>', '<stub>')}")
import os.path
print(f"...in format <folder>{os.path.sep}<stub>")(.venv) C:\clones\typeshed>C:\clones\typeshed\.venv\Scripts\python.exe c:/clones/typeshed/pp.py
...in format <folder>\<stub>
...in format <folder>\<stub>I prefer pathlib because it's a little more semantic.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
project: infrastructuretypeshed build, test, or distribution relatedtypeshed build, test, or distribution related
Activity
AlexWaygood commentedon May 4, 2025
Interesting! I used to use Windows, and ran this script regularly, and never ran into any problems. I believe @Avasam still uses Windows, and he was the original author of this script, so it surprises me that it doesn't work on your machine. I was under the impression that
/was a valid path separator on Windows, it just wasn't the default separator.I don't mind too much making the changes you suggest, but I'm surprised that they're necessary. Are you able to give us any more information about your setup?
Avasam commentedon May 4, 2025
It is.
Either slashes should work fine. (even prepended by
./or.\due to tab-completion)I'm guessing an issue with the pytype script (found 1-2 whilst working on #13795, I just haven't taken the time to extract them). In fact, I cannot replicate this failure on that branch (but I can on main!)
tbf it's possible I missed issues with the pytype script (or passing args to it) as I never run it under Windows. Reason being I prefer Python 3.13 for the new REPL (and pytype doesn't support 3.13). My alternate venv is for Linux (which I just run under WSL2, almost exclusively for pytype)
In other words, I see
tests\runtests.py stdlib/ast.pyifailing as the bug.I generally avoid backslashes in doc/helpers because they can be very annoying to copy (copying a path on windows and deduplicating
\\is so annoying. So is copying a backslash somewhere and having it accidentally escape a character)Avasam commentedon May 4, 2025
Line 101 assumes filename is using system's default separator.
Line 115 asserts.
typeshed/tests/pytype_test.py
Lines 97 to 117 in a4d3f6f
AlexWaygood commentedon May 4, 2025
Ahh, that explains it. I never actually ran pytype_test.py on Windows (could never be bothered to get WSL setup 😃)
hunterhogan commentedon May 5, 2025
Yes, here is some more info. It's pretty much what @Avasam found.
installing pytype
I installed pytype in the following way. Should I trust the installation? (I do not understand wheels and eggs and unwheels or whatever the other methods are.)
editable wasn't necessary
I am very surprised that I did not need to install ts_utils as editable. (The above installation.)
Avasam commentedon May 5, 2025
Right now editable install of
ts_utilswould only be needed so that you don't need to re-install every time you do a modification.It would also be a nice-to-have to ensure some path locations independent of current working directory.
That is indeed how you should install pytype. The latest version is Windows compatible.
It's just that pytype doesn't work on Python 3.13 yet.
hunterhogan commentedon May 5, 2025
Wait, are you saying "blindness to path locations" is a Python-wide issue and not merely one of the eleventy jillion things I don't know how to do?!
hunterhogan/hunterMakesPy#1
(I'm sorry for going so far off topic, but this issue has vexed me since my first Python modules. And thank you both for the feedback and questions. @AlexWaygood )
hunterhogan commentedon May 6, 2025
FYI, more precisely, a forward slash
/can be valid. For example:pushddoesn't have switches, so the cmd interpreter isn't confusing the forward slash for a switch. In this case, the forward slash is interpreted as a malformed server path, not as part of a path.Furthermore, the syntax for path is strict.
(.venv) C:\apps\astToolkit>pushd 'typeshed/stdlib' The syntax of the command is incorrect.