From 71fb26c76bc71fcc51a5124f40f4b3e242b437c5 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Wed, 1 Feb 2017 16:47:15 +0000 Subject: [PATCH] Patch PYTHONPATH when running tests Fixes running tests with packages --user installed. Prompted by jupyter/notebook#2111 --- ipykernel/tests/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ipykernel/tests/__init__.py b/ipykernel/tests/__init__.py index bd839bab7..1a392137c 100644 --- a/ipykernel/tests/__init__.py +++ b/ipykernel/tests/__init__.py @@ -3,6 +3,7 @@ import os import shutil +import sys import tempfile try: @@ -24,7 +25,11 @@ def setup(): global tmp tmp = tempfile.mkdtemp() patchers[:] = [ - patch.dict(os.environ, {'HOME': tmp}), + patch.dict(os.environ, { + 'HOME': tmp, + # Let tests work with --user install when HOME is changed: + 'PYTHONPATH': os.pathsep.join(sys.path), + }), ] for p in patchers: p.start()