mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 00:41:00 +01:00

* refactor: remove usage of global variables in abbrevs.py * chore: add flake8-mutable to prevent mutable defaults * fix: abbrevs expand test * refactor: add xonsh session singleton * refactor: fix circular errors when using xonshSession as singleton * refactor: remove black magicked builtin attributes * style: black format tests as well * refactor: update tests to use xonsh-session singleton * refactor: update abbrevs to not use builtins * test: remove DummyCommandsCache and patch orig class * fix: failing test_command_completers * test: use monkeypatch to update xession fixture * fix: failing test_pipelines * fix: failing test_main * chore: run test suit as single invocation * test: fix tests/test_xonsh.xsh * refactor: remove builtins from docs/conf.py * fix: mypy error in jobs * fix: test error from test_main * test: close xession error in test_command_completers * chore: use pytest-cov for reporting coverage this will include subprocess calls, and will increase coverage * style:
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
"""Tests bashisms xontrib."""
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"history, inp, exp",
|
|
[
|
|
# No history:
|
|
([], "!!", ""),
|
|
([], "!$", ""),
|
|
([], "!^", ""),
|
|
([], "!*", ""),
|
|
([], "!echo", ""),
|
|
# No substitution:
|
|
(["aa 1 2", "ab 3 4"], "ls", "ls"),
|
|
(["aa 1 2", "ab 3 4"], "x = 42", "x = 42"),
|
|
(["aa 1 2", "ab 3 4"], "!", "!"),
|
|
# Bang command only:
|
|
(["aa 1 2", "ab 3 4"], "!!", "ab 3 4"),
|
|
(["aa 1 2", "ab 3 4"], "!$", "4"),
|
|
(["aa 1 2", "ab 3 4"], "!^", "ab"),
|
|
(["aa 1 2", "ab 3 4"], "!*", "3 4"),
|
|
(["aa 1 2", "ab 3 4"], "!a", "ab 3 4"),
|
|
(["aa 1 2", "ab 3 4"], "!aa", "aa 1 2"),
|
|
(["aa 1 2", "ab 3 4"], "!ab", "ab 3 4"),
|
|
# Bang command with others:
|
|
(["aa 1 2", "ab 3 4"], "echo !! >log", "echo ab 3 4 >log"),
|
|
(["aa 1 2", "ab 3 4"], "echo !$ >log", "echo 4 >log"),
|
|
(["aa 1 2", "ab 3 4"], "echo !^ >log", "echo ab >log"),
|
|
(["aa 1 2", "ab 3 4"], "echo !* >log", "echo 3 4 >log"),
|
|
(["aa 1 2", "ab 3 4"], "echo !a >log", "echo ab 3 4 >log"),
|
|
(["aa 1 2", "ab 3 4"], "echo !aa >log", "echo aa 1 2 >log"),
|
|
(["aa 1 2", "ab 3 4"], "echo !ab >log", "echo ab 3 4 >log"),
|
|
],
|
|
)
|
|
def test_preproc(history, inp, exp, xession):
|
|
"""Test the bash preprocessor."""
|
|
from xontrib.bashisms import bash_preproc
|
|
|
|
xession.history.inps = history
|
|
obs = bash_preproc(inp)
|
|
assert exp == obs
|