[py-dev] Problems with DOS files
Matthew Scott
mscott at goldenspud.com
Tue Jan 18 02:00:24 CET 2005
Patrick K. O'Brien wrote:
>>Is there
>>anything similarly simple that can be done under windows?
>
>
> Not that I'm aware of. :-(
>
> Take that back. Courtesy of Matthew Scott, here is a clever, two-line
> solution (concatenate that second line if it breaks):
>
> pytest.bat
> ==========
> @echo off
> python -c "import py; from py.__impl__.test.cmdline import main; main()" %1
> %2 %3 %4 %5 %6 %7 %8 %9
Just had to do something similar with a Schevo script, so here's a new
version that can be put into py\bin as pytest.cmd:
@echo off
python %~dp0\py.test %*
Not sure if it will work on non-NT-based systems, or with a .bat
extension instead of .cmd, but this style seems to work great for the
other script I had to write. Above py.test script is untested by me
though since I avoid Windows whenever possible. :)
Opening this URL in Internet Explorer will shed some light on the
"advanced" batch file syntax, at least on Windows XP:
ms-its:C:\WINDOWS\Help\ntcmds.chm::/percent.htm
Basically, %~dp0 resolves to the drive and directory of the pytest.cmd
file that was executed, and %* is the rest of the command-line arguments
given to the batch file. The py\bin directory needs to be in the PATH
environment variable but everything else is done via Py's magic :)
- Matthew
More information about the Pytest-dev
mailing list