From e70d7c76f3519719496b46bf5391e5768a83d8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=C5=9Aliwi=C5=84ski?= Date: Tue, 4 Jun 2024 12:56:13 +0200 Subject: [PATCH] Pass LC and LANG envvars to pg_ctl calls - closes #343 --- newsfragments/343.bugfix.rst | 2 ++ pytest_postgresql/executor.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 newsfragments/343.bugfix.rst diff --git a/newsfragments/343.bugfix.rst b/newsfragments/343.bugfix.rst new file mode 100644 index 00000000..c89c39a9 --- /dev/null +++ b/newsfragments/343.bugfix.rst @@ -0,0 +1,2 @@ +Fixed a long-standing bug, where calls to pg_ctl weren't getting `LC_*` and `LANG` envvars, +which caused issues on some systems not recognizing --auth parameter. \ No newline at end of file diff --git a/pytest_postgresql/executor.py b/pytest_postgresql/executor.py index 25797492..6fb10322 100644 --- a/pytest_postgresql/executor.py +++ b/pytest_postgresql/executor.py @@ -177,11 +177,13 @@ def init_directory(self) -> None: password_file.write(password) password_file.flush() init_directory += ["-o", " ".join(options)] - subprocess.check_output(init_directory) + # Passing envvars to command to avoid weird MacOs error. + subprocess.check_output(init_directory, env=self._envvars) else: options += ["--auth=trust"] init_directory += ["-o", " ".join(options)] - subprocess.check_output(init_directory) + # Passing envvars to command to avoid weird MacOs error. + subprocess.check_output(init_directory, env=self._envvars) self._directory_initialised = True