From d351df384a4d880fa5eaee8ce1f9c757a82a1350 Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Mon, 24 Jun 2024 21:12:23 +0200 Subject: [PATCH] tests: SpecAttrModifierAlias: integration test (#5533) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- tests/test_integrations.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_integrations.py b/tests/test_integrations.py index 24903c13f..b3b033564 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -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():