4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
31 class ErrorsTestCase(unittest.TestCase):
32 def test_BuildError(self):
33 """Test the BuildError exception."""
35 raise SCons.Errors.BuildError(
36 errstr = "foo", status=57, filename="file", exc_info=(1,2,3),
37 node = "n", executor="e", action="a", command="c")
38 except SCons.Errors.BuildError, e:
39 assert e.errstr == "foo"
41 assert e.exitstatus == 2, e.exitstatus
42 assert e.filename == "file"
43 assert e.exc_info == (1,2,3)
46 assert e.executor == "e"
47 assert e.action == "a"
48 assert e.command == "c"
51 raise SCons.Errors.BuildError("n", "foo", 57, 3, "file",
52 "e", "a", "c", (1,2,3))
53 except SCons.Errors.BuildError, e:
54 assert e.errstr == "foo", e.errstr
55 assert e.status == 57, e.status
56 assert e.exitstatus == 3, e.exitstatus
57 assert e.filename == "file", e.filename
58 assert e.exc_info == (1,2,3), e.exc_info
61 assert e.executor == "e"
62 assert e.action == "a"
63 assert e.command == "c"
66 raise SCons.Errors.BuildError()
67 except SCons.Errors.BuildError, e:
68 assert e.errstr == "Unknown error"
70 assert e.exitstatus == 2
71 assert e.filename is None
72 assert e.exc_info == (None, None, None)
75 assert e.executor is None
76 assert e.action is None
77 assert e.command is None
79 def test_InternalError(self):
80 """Test the InternalError exception."""
82 raise SCons.Errors.InternalError, "test internal error"
83 except SCons.Errors.InternalError, e:
84 assert e.args == ("test internal error",)
86 def test_UserError(self):
87 """Test the UserError exception."""
89 raise SCons.Errors.UserError, "test user error"
90 except SCons.Errors.UserError, e:
91 assert e.args == ("test user error",)
93 def test_ExplicitExit(self):
94 """Test the ExplicitExit exception."""
96 raise SCons.Errors.ExplicitExit, "node"
97 except SCons.Errors.ExplicitExit, e:
98 assert e.node == "node"
100 if __name__ == "__main__":
101 suite = unittest.makeSuite(ErrorsTestCase, 'test_')
102 if not unittest.TextTestRunner().run(suite).wasSuccessful():
107 # indent-tabs-mode:nil
109 # vim: set expandtab tabstop=4 shiftwidth=4: