Skip to content

Commit

Permalink
Fix for failing tests on CI with no locale set (#1311)
Browse files Browse the repository at this point in the history
Update the tests so they support running on a system where Python is
not able to determine the default locale.
  • Loading branch information
EdwardBetts authored Sep 2, 2024
1 parent 71a6c08 commit 9ed3aff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion tests/cli/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ def test_list_vehicles_prompt(
)
assert result.exit_code == 0, result.exception

default_locale = getdefaultlocale()[0]
prompt_default = f" [{default_locale}]" if default_locale else ""

expected_output = (
f"Please select a locale [{getdefaultlocale()[0]}]: {TEST_LOCALE}\n"
f"Please select a locale{prompt_default}: {TEST_LOCALE}\n"
"Do you want to save the locale to the credential store? [y/N]: N\n"
"\n"
f"User: {TEST_USERNAME}\n"
Expand Down
9 changes: 7 additions & 2 deletions tests/cli/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ def test_login_prompt(mocked_responses: aioresponses, cli_runner: CliRunner) ->
input=f"{TEST_USERNAME}\n{TEST_PASSWORD}\n{TEST_LOCALE}\ny",
)
assert result.exit_code == 0, result.exception
default_locale = getdefaultlocale()[0]
prompt_default = f" [{default_locale}]" if default_locale else ""

expected_output = (
f"User: {TEST_USERNAME}\n"
"Password: \n"
f"Please select a locale [{getdefaultlocale()[0]}]: {TEST_LOCALE}\n"
f"Please select a locale{prompt_default}: {TEST_LOCALE}\n"
"Do you want to save the locale to the credential store? [y/N]: y\n"
"\n"
)
Expand Down Expand Up @@ -70,9 +73,11 @@ def test_list_accounts_prompt(
input=f"{TEST_LOCALE}\nN\n{TEST_USERNAME}\n{TEST_PASSWORD}\n",
)
assert result.exit_code == 0, result.exception
default_locale = getdefaultlocale()[0]
prompt_default = f" [{default_locale}]" if default_locale else ""

expected_output = (
f"Please select a locale [{getdefaultlocale()[0]}]: {TEST_LOCALE}\n"
f"Please select a locale{prompt_default}: {TEST_LOCALE}\n"
"Do you want to save the locale to the credential store? [y/N]: N\n"
"\n"
f"User: {TEST_USERNAME}\n"
Expand Down
5 changes: 4 additions & 1 deletion tests/cli/test_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,11 @@ def test_vehicle_status_prompt(
)
assert result.exit_code == 0, result.exception

default_locale = getdefaultlocale()[0]
prompt_default = f" [{default_locale}]" if default_locale else ""

expected_output = (
f"Please select a locale [{getdefaultlocale()[0]}]: {TEST_LOCALE}\n"
f"Please select a locale{prompt_default}: {TEST_LOCALE}\n"
"Do you want to save the locale to the credential store? [y/N]: N\n"
"\n"
f"User: {TEST_USERNAME}\n"
Expand Down

0 comments on commit 9ed3aff

Please sign in to comment.