From a24d7dc71784f9fa06d15c2d5d709c6b39286452 Mon Sep 17 00:00:00 2001 From: bhelgs <33836927+bhelgs@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:52:08 -0400 Subject: [PATCH] add support for \ character in pytest temporary path - Closes #982 --- newsfragments/982.feature.rst | 1 + pytest_postgresql/executor.py | 8 ++++---- tests/test_executor.py | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 newsfragments/982.feature.rst diff --git a/newsfragments/982.feature.rst b/newsfragments/982.feature.rst new file mode 100644 index 00000000..68346c3f --- /dev/null +++ b/newsfragments/982.feature.rst @@ -0,0 +1 @@ +add support for \\ character in pytest temporary path \ No newline at end of file diff --git a/pytest_postgresql/executor.py b/pytest_postgresql/executor.py index 6fb10322..c2af578e 100644 --- a/pytest_postgresql/executor.py +++ b/pytest_postgresql/executor.py @@ -49,11 +49,11 @@ class PostgreSQLExecutor(TCPExecutor): """ BASE_PROC_START_COMMAND = ( - "{executable} start -D {datadir} " + '{executable} start -D "{datadir}" ' "-o \"-F -p {port} -c log_destination='stderr' " "-c logging_collector=off " "-c unix_socket_directories='{unixsocketdir}' {postgres_options}\" " - "-l {logfile} {startparams}" + '-l "{logfile}" {startparams}' ) VERSION_RE = re.compile(r".* (?P\d+(?:\.\d+)?)") @@ -216,13 +216,13 @@ def running(self) -> bool: """Check if server is running.""" if not os.path.exists(self.datadir): return False - status_code = subprocess.getstatusoutput(f"{self.executable} status -D {self.datadir}")[0] + status_code = subprocess.getstatusoutput(f'{self.executable} status -D "{self.datadir}"')[0] return status_code == 0 def stop(self: T, sig: Optional[int] = None, exp_sig: Optional[int] = None) -> T: """Issue a stop request to executable.""" subprocess.check_output( - f"{self.executable} stop -D {self.datadir} -m f", + f'{self.executable} stop -D "{self.datadir}" -m f', shell=True, ) try: diff --git a/tests/test_executor.py b/tests/test_executor.py index 9706f630..56e52861 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -96,7 +96,6 @@ def test_executor_init_with_password( assert_executor_start_stop(executor) -@pytest.mark.xfail(reason="issue tracked by #982") def test_executor_init_bad_tmp_path( request: FixtureRequest, tmp_path_factory: pytest.TempPathFactory,