pass sys.path to subprocess PYTHONPATH

1,905 views
Skip to first unread message

tom.bro...@gmail.com

unread,
Oct 13, 2008, 8:59:55 PM10/13/08
to joe.hug...@gmail.com, googletran...@googlegroups.com
Reviewers: Joe Hughes,

Description:
Setting PYTHONPATH of the process running the unittest code should also
affect tests that run in a subprocess.
The downside of this change is that the subprocess tests no longer check
that everything will work by default once you've installed transitfeed.
Hopefully if your tests are using a customized sys.path you know what
you are doing.

Please review this at http://codereview.appspot.com/7469

Affected files:
M python/test/util.py


Index: python/test/util.py
===================================================================
--- python/test/util.py (revision 893)
+++ python/test/util.py (working copy)
@@ -92,9 +92,11 @@
transitfeed_parent = transitfeed_parent.replace("\\", "/").rstrip("/")
script_path = cmd[0].replace("\\", "/")
script_args = cmd[1:]
+ env = {"PYTHONPATH": ":".join(sys.path)}

cmd = [sys.executable,
"-c",
"import sys; sys.path.insert(0,'%s');exec(open('%s'))" %
(transitfeed_parent, script_path)] + script_args
- return check_call(cmd, expected_retcode=expected_retcode, shell=False)
+ return check_call(cmd, expected_retcode=expected_retcode, shell=False,
+ env=env)


joe.hug...@gmail.com

unread,
Oct 13, 2008, 9:03:42 PM10/13/08
to tom.bro...@gmail.com, googletran...@googlegroups.com
Looks good, thanks.


http://codereview.appspot.com/7469/diff/1/2
File python/test/util.py (right):

http://codereview.appspot.com/7469/diff/1/2#newcode95
Line 95: env = {"PYTHONPATH": ":".join(sys.path)}
Could you add a comment here similar to what you wrote in the change
description?

http://codereview.appspot.com/7469

Tom Brown

unread,
Oct 14, 2008, 10:31:37 AM10/14/08
to joe.hug...@gmail.com, googletran...@googlegroups.com
On Mon, Oct 13, 2008 at 18:03, <joe.hug...@gmail.com> wrote:
http://codereview.appspot.com/7469/diff/1/2#newcode95
Line 95: env = {"PYTHONPATH": ":".join(sys.path)}
Could you add a comment here similar to what you wrote in the change
description?

Done and submitted.

Reply all
Reply to author
Forward
0 new messages