bh@123: # Copyright (C) 2008 by Intevation GmbH bh@123: # Authors: bh@123: # Bernhard Herzog bh@123: # bh@123: # This program is free software under the GPL (>=v2) bh@123: # Read the file COPYING coming with the software for details. bh@123: bh@123: """Tests for treepkg.run""" bh@123: bh@123: import sys bh@123: import os bh@123: import unittest bh@123: bh@123: from treepkg.run import call, SubprocessError bh@123: bh@123: bh@123: bh@123: class TestCall(unittest.TestCase): bh@123: bh@123: def test_call_defaults(self): bh@123: call([sys.executable, "-c", "pass"]) bh@123: bh@123: def test_call_error(self): bh@123: """Test call with a subprocess that exits with a non-zero exit code""" bh@123: try: bh@123: call([sys.executable, "-c", "import sys; sys.exit(1)"]) bh@123: except SubprocessError, exc: bh@123: self.assertEquals(exc.returncode, 1) bh@123: else: bh@123: self.fail("call did not raise an exception")