mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
allow test_raise_subproc_error_with_show_traceback
to be run locally (#5461)
previously, this succeeded in CI, but always failed locally with the
following error:
```xsh
_____________________________________________________________________ test_raise_subproc_error_with_show_traceback[True] _____________________________________________________________________
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x76f6ba8882e0>, interactive = True
@skip_if_on_windows
@pytest.mark.parametrize("interactive", [True, False])
def test_raise_subproc_error_with_show_traceback(monkeypatch, interactive):
out, err, ret = run_xonsh(
"$COLOR_RESULTS=False\n$RAISE_SUBPROC_ERROR=False\n$XONSH_SHOW_TRACEBACK=False\nls nofile",
interactive=interactive,
single_command=True,
)
assert ret != 0
> assert re.match("ls.*No such file or directory\n", out)
E assert None
E + where None = <function match at 0x76f6bcd0cd30>('ls.*No such file or directory\n', "\x1b]0;ls | jyn@pop-os: ~/src/xonsh | xonsh\x07ls: cannot access 'nofile': No such file or directory\n")
E + where <function match at 0x76f6bcd0cd30> = re.match
tests/test_integrations.py:1190: AssertionError
```
the problem was that the following string was prepended before the error
message:
```
\x1b]0;ls | jyn@pop-os: ~/src/xonsh | xonsh\x07l
```
that in turn came from
[`BaseShell.settitle`](66c0490d37/xonsh/base_shell.py (L570)
),
which always prepends at least the escape codes even when TITLE is set
to an empty string.
avoid this issue by mimicking a dumb terminal in tests, in which case
`settitle` doesn't add any title at all.
see
https://xonsh.zulipchat.com/#narrow/stream/435069-xonsh-dev/topic/Running.20tests.20locally
for more context.
<!---
Thanks for opening a PR on xonsh!
Please do this:
1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.
-->
## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
This commit is contained in:
parent
fccdd021c4
commit
a953c29443
1 changed files with 2 additions and 0 deletions
|
@ -63,6 +63,8 @@ def run_xonsh(
|
||||||
env["RAISE_SUBPROC_ERROR"] = "0"
|
env["RAISE_SUBPROC_ERROR"] = "0"
|
||||||
env["FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE"] = "1"
|
env["FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE"] = "1"
|
||||||
env["PROMPT"] = ""
|
env["PROMPT"] = ""
|
||||||
|
# disable ansi escape codes
|
||||||
|
env["TERM"] = "linux"
|
||||||
xonsh = shutil.which("xonsh", path=PATH)
|
xonsh = shutil.which("xonsh", path=PATH)
|
||||||
args = [xonsh, "--no-rc"]
|
args = [xonsh, "--no-rc"]
|
||||||
if interactive:
|
if interactive:
|
||||||
|
|
Loading…
Add table
Reference in a new issue