2 # Copyright (c) 2015-2016, 2019 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 """Tests for the exceptions module."""
26 from framework
import exceptions
28 # Good test names often are not PEP8
29 # pylint: disable=invalid-name
32 @pytest.mark
.raises(exception
=SystemExit)
34 def test_handle_PiglitFatalError():
35 """exceptions.handler: Handles PiglitFatalError"""
36 raise exceptions
.PiglitFatalError
39 @pytest.mark
.raises(exception
=SystemExit)
41 def test_handle_PiglitAbort():
42 """exceptions.handler: Handles PiglitAbort"""
43 raise exceptions
.PiglitAbort
46 @pytest.mark
.raises(exception
=SystemExit)
48 def test_handle_PiglitUserError():
49 """exceptions.handler: Handles PiglitUserError"""
50 raise exceptions
.PiglitUserError
64 def f3(param
, unused
):
65 return param
, len(param
)
68 @pytest.mark
.parametrize("function, param, expected", [
72 (f3
, ("testing", 1), ("testing", 7)),
73 (f3
, ("more testing", 2), ("more testing", 12)),
75 def test_handle_return(function
, param
, expected
):
76 if type(param
) is tuple:
77 value
= function(*param
)
79 value
= function(param
)
80 assert value
== expected