annotate test/test_run.py @ 123:37aadd33ffab

Add tests for treepkg/run.py
author Bernhard Herzog <bh@intevation.de>
date Thu, 22 May 2008 10:40:08 +0000
parents
children e08b4b09d35f
rev   line source
123
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
1 # Copyright (C) 2008 by Intevation GmbH
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Authors:
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Bernhard Herzog <bh@intevation.de>
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 #
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 # This program is free software under the GPL (>=v2)
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 # Read the file COPYING coming with the software for details.
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8 """Tests for treepkg.run"""
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10 import sys
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11 import os
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 import unittest
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
13
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14 from treepkg.run import call, SubprocessError
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18 class TestCall(unittest.TestCase):
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
19
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20 def test_call_defaults(self):
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21 call([sys.executable, "-c", "pass"])
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23 def test_call_error(self):
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24 """Test call with a subprocess that exits with a non-zero exit code"""
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25 try:
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
26 call([sys.executable, "-c", "import sys; sys.exit(1)"])
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
27 except SubprocessError, exc:
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
28 self.assertEquals(exc.returncode, 1)
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29 else:
37aadd33ffab Add tests for treepkg/run.py
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
30 self.fail("call did not raise an exception")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)