Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make test locale independent #7411

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions tests/console/commands/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,23 @@ def test_run_keeps_options_passed_before_command(
def test_run_has_helpful_error_when_command_not_found(
app_tester: ApplicationTester, env: MockEnv, capfd: pytest.CaptureFixture[str]
):
nonexistent_command = "nonexistent-command"
env._execute = True
app_tester.execute("run nonexistent-command")
app_tester.execute(f"run {nonexistent_command}")

assert env.executed == [["nonexistent-command"]]
assert env.executed == [[nonexistent_command]]
assert app_tester.status_code == 1
if WINDOWS:
# On Windows we use a shell to run commands which provides its own error
# message when a command is not found that is not captured by the
# ApplicationTester but is captured by pytest, and we can access it via capfd.
# The expected string in this assertion assumes Command Prompt (cmd.exe) is the
# shell used.
assert capfd.readouterr().err.splitlines() == [
(
"'nonexistent-command' is not recognized as an internal or external"
" command,"
),
"operable program or batch file.",
]
# The exact error message depends on the system language. Thus, we check only
# for the name of the command.
assert nonexistent_command in capfd.readouterr().err
else:
assert app_tester.io.fetch_error() == "Command not found: nonexistent-command\n"
assert (
app_tester.io.fetch_error() == f"Command not found: {nonexistent_command}\n"
)


@pytest.mark.skipif(
Expand Down