Skip to content

Instantly share code, notes, and snippets.

@gforsyth
Created March 14, 2024 13:21
Show Gist options
  • Save gforsyth/b07799771dd530ee51ad6bc3068b25bb to your computer and use it in GitHub Desktop.
Save gforsyth/b07799771dd530ee51ad6bc3068b25bb to your computer and use it in GitHub Desktop.
import sys
from xonsh.imphooks import XonshImportHook
from xonsh.execer import Execer
sys.meta_path.append(XonshImportHook(Execer()))
from tiny_scriptlet import *
def test_xonsh_function():
assert xonsh_function() == "hello there"
def test_alias():
assert $(hello).strip() == "hello there"
def xonsh_function():
return $(echo hello there).strip()
aliases["hello"] = xonsh_function
@gforsyth
Copy link
Author

🐚 pytest test_tiny_scriptlet.xsh -v
================================ test session starts ================================
platform linux -- Python 3.10.12, pytest-8.0.0, pluggy-1.3.0 -- /home/gil/mambaforge/bin/python
cachedir: .pytest_cache
rootdir: /home/gil/github.com/gforsyth/xsh_test_example
plugins: rerunfailures-13.0, xonsh-0.15.1, cov-4.1.0, mock-3.12.0, timeout-2.2.0, subprocess-1.5.0
collected 2 items                                                                   

test_tiny_scriptlet.xsh::test_alias PASSED                                    [ 50%]
test_tiny_scriptlet.xsh::test_xonsh_function PASSED                           [100%]

================================= 2 passed in 0.03s =================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment