AssertWT¶
Assert that a Python script is run in the Windows Terminal ‘wt.exe’ instead of the standard ‘conhost.exe’ console.
>>> import assertwt
>>> assertwt.restart()
By default the script is run with cmd.exe and the window is closed when the script ends.
# Default behaviour: cmd.exe and window closes after script:
assertwt.restart(["wt", "-d", assertwt.CD, "cmd", "/C", assertwt.ARGV])
# cmd.exe and windows does not close after script:
assertwt.restart(["wt", "-d", assertwt.CD, "cmd", "/K", assertwt.ARGV])
# Powershell and window closes after script:
assertwt.restart(["wt", "-d", assertwt.CD, "powershell", "-Command", assertwt.ARGV])
# Powershell and windows does not close after script:
assertwt.restart(["wt", "-d", assertwt.CD, "powershell", "-NoExit", "-Command", assertwt.ARGV])
# New tab in existing Windows Terminal window:
assertwt.restart(["wt", "new-tab", "-d", assertwt.CD, "cmd", "/K", assertwt.ARGV])
Install¶
pip install assertwt
See: https://pypi.org/project/assertwt/
Functions¶
- assertwt.restart(args=['wt', '-d', <function CD>, 'cmd', '/C', <function ARGV>])[source]¶
Restarts the script in the ‘Windows Terminal’ if it is available
- Parameters:
args –
Choose how to run the script:
CMD:
["wt", "-d", assertwt.CD, "cmd", "/C", assertwt.ARGV]
CMD (no exit):
["wt", "-d", assertwt.CD, "cmd", "/K", assertwt.ARGV]
Powershell:
["wt", "-d", assertwt.CD, "powershell", "-NoExit", "-Command", assertwt.ARGV]
Powershell (no exit):
["wt", "-d", assertwt.CD, "powershell", "-Command", assertwt.ARGV]