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

Cannot create postgresql_proc on a system where LANG is not set #853

Open
jjudas-resistant opened this issue Nov 28, 2023 · 1 comment
Open

Comments

@jjudas-resistant
Copy link

What action do you want to perform

Run a unit test with the postgresql_proc fixture, for example

def simple_test(postgresql_proc: PostgreSQLExecutor) -> None:
    assert postgresql_proc.dbname

What are the results

initdb: error: invalid locale settings; check LANG and LC_* environment variables
pg_ctl: database system initialization failed

What are the expected results

The test runs successfully.

It looks like for pg_ctl calls that are going through TCPExecutor, there is an override being passed for the locale env vars. But for the pg_ctl calls which are directly in PostgreSQLExecutor, no such thing is done.

I guess a quick solution would be to create a private method for running subprocesses instead of calling subprocess.check_output directly in init_directory and version. This method could then override the env and set LC_ALL, LC_CTYPE and LANG (although it looks like only LANG is necessary). If this solution sounds OK to you, I'll be happy to try to create a PR.

@fizyk
Copy link
Member

fizyk commented Dec 15, 2023

@jjudas-resistant I think that would be acceptable, with probably some warning left. Since I'm not sure if that would be the desired solution. the LANG might change the output message language (for debugging purpose certain language might be more desirable for the user)

Though we do test against different locale's
https://github.com/ClearcodeHQ/pytest-postgresql/blob/main/.github/workflows/single-postgres.yml#L48
https://github.com/ClearcodeHQ/pytest-postgresql/blob/main/tests/test_executor.py#L52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants