tests: SpecAttrModifierAlias: integration test (#5533)

Added test.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Andy Kipp 2024-06-24 21:12:23 +02:00 committed by GitHub
parent 3e41a744d4
commit d351df384a
Failed to generate hash of commit

View file

@ -1331,6 +1331,26 @@ def test_alias_stability():
assert re.match(".*sleep.*sleep.*sleep.*", out, re.MULTILINE | re.DOTALL)
@skip_if_on_windows
@pytest.mark.flaky(reruns=3, reruns_delay=1)
def test_spec_modifier_alias():
"""Testing spec modifier alias with `@` in the alias name."""
stdin_cmd = (
"from xonsh.procs.specs import SpecAttrModifierAlias as mod\n"
'aliases["@dict"] = mod({"output_format": lambda lines: eval("\\n".join(lines))})\n'
"d = $(@dict echo '{\"a\":42}')\n"
"print('Answer =', d['a'])\n"
)
out, err, ret = run_xonsh(
cmd=None,
stdin_cmd=stdin_cmd,
interactive=True,
single_command=False,
timeout=10,
)
assert "Answer = 42" in out
@skip_if_on_windows
@pytest.mark.flaky(reruns=3, reruns_delay=1)
def test_alias_stability_exception():