Mercurial > treepkg
comparison test/test_run.py @ 124:e08b4b09d35f
New parameter treepkg.run.call: extra_env for additional environment
variables passed to the subprocess. Also add a test case.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 22 May 2008 12:44:43 +0000 |
parents | 37aadd33ffab |
children | a68a4e22549c |
comparison
equal
deleted
inserted
replaced
123:37aadd33ffab | 124:e08b4b09d35f |
---|---|
26 call([sys.executable, "-c", "import sys; sys.exit(1)"]) | 26 call([sys.executable, "-c", "import sys; sys.exit(1)"]) |
27 except SubprocessError, exc: | 27 except SubprocessError, exc: |
28 self.assertEquals(exc.returncode, 1) | 28 self.assertEquals(exc.returncode, 1) |
29 else: | 29 else: |
30 self.fail("call did not raise an exception") | 30 self.fail("call did not raise an exception") |
31 | |
32 def test_call_extra_env(self): | |
33 """Test call with the extra_env parameter""" | |
34 subprocess_cmd = [sys.executable, "-c", | |
35 "import sys, os;" | |
36 "value = os.environ.get('TREEPKG_TEST');" | |
37 "sys.exit(int(value != 'xyzzy'))" | |
38 ] | |
39 # sanity check that the extra environment variable we use for | |
40 # the test is not set yet | |
41 self.assertRaises(SubprocessError, call, subprocess_cmd) | |
42 | |
43 # the actual test | |
44 try: | |
45 call(subprocess_cmd, extra_env=dict(TREEPKG_TEST="xyzzy")) | |
46 except SubprocessError, exc: | |
47 self.fail("the extra_env variables were not set properly") | |
48 else: | |
49 # test OK | |
50 pass |