-
The documentation says nothing about how to write unit tests for .xsh scripts. I reckon pytest can be used for this purpose but there is no information provided on how to set it up such that it doesn't get tripped on xonsh specific syntax. |
Beta Was this translation helpful? Give feedback.
Answered by
gforsyth
Mar 14, 2024
Replies: 1 comment 1 reply
-
Yeah, this should be documented. You have to use the import sys
from xonsh.imphooks import XonshImportHook
from xonsh.execer import Execer
sys.meta_path.append(XonshImportHook(Execer())) at the top of your Gist here for full example: https://gist.github.com/gforsyth/b07799771dd530ee51ad6bc3068b25bb |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
anki-code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, this should be documented.
You have to use the
XonshImportHook
and a bit ofmeta_path
hacking, so you do:at the top of your
test_
file. And the tests can be written in either a.py
file or a.xsh
file.Gist here for full example: https://gist.github.com/gforsyth/b07799771dd530ee51ad6bc3068b25bb