]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix missing pythonpath in test that use subprocess
authorFederico Caselli <cfederico87@gmail.com>
Mon, 15 Apr 2024 19:52:38 +0000 (21:52 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Mon, 15 Apr 2024 19:52:38 +0000 (21:52 +0200)
Ensure the ``PYTHONPATH`` variable is properly initialized when
using ``subprocess.run`` in the tests.

Fixes: #11268
Change-Id: Ie2db656364931b3be9033dcaaf7a7c56b383ecca

doc/build/changelog/unreleased_20/11268.rst [new file with mode: 0644]
test/sql/test_resultset.py

diff --git a/doc/build/changelog/unreleased_20/11268.rst b/doc/build/changelog/unreleased_20/11268.rst
new file mode 100644 (file)
index 0000000..40c1eb7
--- /dev/null
@@ -0,0 +1,6 @@
+.. change::
+    :tags: bug, test
+    :tickets: 11268
+
+    Ensure the ``PYTHONPATH`` variable is properly initialized when
+    using ``subprocess.run`` in the tests.
index 938df1ac3af828c82ab5cfe53c1834081442ddf4..e6d02da7e9429fa46ca3d53cab010ea5a4172604 100644 (file)
@@ -530,8 +530,14 @@ class CursorResultTest(fixtures.TablesTest):
             "import sqlalchemy; import pickle; print(["
             f"r[0] for r in pickle.load(open('''{name}''', 'rb'))])"
         )
+        parts = list(sys.path)
+        if os.environ.get("PYTHONPATH"):
+            parts.append(os.environ["PYTHONPATH"])
+        pythonpath = os.pathsep.join(parts)
         proc = subprocess.run(
-            [sys.executable, "-c", code], stdout=subprocess.PIPE
+            [sys.executable, "-c", code],
+            stdout=subprocess.PIPE,
+            env={**os.environ, "PYTHONPATH": pythonpath},
         )
         exp = str([r[0] for r in result]).encode()
         eq_(proc.returncode, 0)