enqueue-fill-buffer: improve array formatting
[piglit.git] / unittests / framework / test_exceptions.py
blob4744568fc051f99bbf2905052064760cfae3ee3e
1 # coding=utf-8
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
20 # SOFTWARE.
22 """Tests for the exceptions module."""
24 import pytest
26 from framework import exceptions
28 # Good test names often are not PEP8
29 # pylint: disable=invalid-name
32 @pytest.mark.raises(exception=SystemExit)
33 @exceptions.handler
34 def test_handle_PiglitFatalError():
35 """exceptions.handler: Handles PiglitFatalError"""
36 raise exceptions.PiglitFatalError
39 @pytest.mark.raises(exception=SystemExit)
40 @exceptions.handler
41 def test_handle_PiglitAbort():
42 """exceptions.handler: Handles PiglitAbort"""
43 raise exceptions.PiglitAbort
46 @pytest.mark.raises(exception=SystemExit)
47 @exceptions.handler
48 def test_handle_PiglitUserError():
49 """exceptions.handler: Handles PiglitUserError"""
50 raise exceptions.PiglitUserError
53 @exceptions.handler
54 def f1():
55 pass
58 @exceptions.handler
59 def f2(param):
60 return param + 1
63 @exceptions.handler
64 def f3(param, unused):
65 return param, len(param)
68 @pytest.mark.parametrize("function, param, expected", [
69 (f1, (), None),
70 (f2, 2, 3),
71 (f2, 5, 6),
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)
78 else:
79 value = function(param)
80 assert value == expected