--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id CEC3E6DE00F5\r
+ for <notmuch@notmuchmail.org>; Fri, 15 Apr 2016 14:18:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.28\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.28 tagged_above=-999 required=5 tests=[AWL=0.289,\r
+ HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id I84KnNaVcBPh for <notmuch@notmuchmail.org>;\r
+ Fri, 15 Apr 2016 14:18:21 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id D15326DE00EB\r
+ for <notmuch@notmuchmail.org>; Fri, 15 Apr 2016 14:18:20 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 4F424100104; Sat, 16 Apr 2016 00:18:15 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Cc: tomi.ollila@iki.fi\r
+Subject: [PATCH] test: test_python: set PYTHONPATH for the duration python is\r
+ executed\r
+Date: Sat, 16 Apr 2016 00:18:14 +0300\r
+Message-Id: <1460755094-22088-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.6.4\r
+In-Reply-To: <1460738800-9021-1-git-send-email-tomi.ollila@iki.fi>\r
+References: <1460738800-9021-1-git-send-email-tomi.ollila@iki.fi>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 15 Apr 2016 21:18:29 -0000\r
+\r
+Set PYTHONPATH for the duration python is executed so environment is\r
+not changed. This also allows appending the old value of PYTHONPATH\r
+to it in case it is set (otherwise it would have been append again and\r
+again when test_python is called).\r
+\r
+At the same time, use -B option to avoid writing .pyc files to\r
+bindings/python/* (which are not cleared out by distclean).\r
+\r
+Drop the (unused) prefix code which preserved the original stdout of the\r
+python program and opened sys.stdout to OUTPUT. In place of that there\r
+is now note how (debug) information can be printed to original stdout.\r
+---\r
+\r
+when doing LD_LIBRARY_PATH this kept irritating me -- and it looks like\r
+this is the last place where environment is changed (using export)\r
+in mid-execution.\r
+\r
+\r
+ test/test-lib.sh | 8 ++++----\r
+ 1 file changed, 4 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 562fde7b8878..5560a9dac3db 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -1164,10 +1164,10 @@ test_emacs () {\r
+ }\r
+ \r
+ test_python() {\r
+- export PYTHONPATH=$TEST_DIRECTORY/../bindings/python\r
+-\r
+- (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \\r
+- | $NOTMUCH_PYTHON -\r
++ # Note: if there is need to print debug information from python program,\r
++ # use stdout = os.fdopen(6, 'w') or stderr = os.fdopen(7, 'w')\r
++ PYTHONPATH="$TEST_DIRECTORY/../bindings/python${PYTHONPATH:+:$PYTHONPATH}" \\r
++ $NOTMUCH_PYTHON -B - > OUTPUT\r
+ }\r
+ \r
+ test_ruby() {\r
+-- \r
+2.6.4\r
+\r