Skip to content

Commit bc23ce7

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add reproducer for bug #1881455"
2 parents 2061ce1 + 03b00ae commit bc23ce7

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2020 Red Hat, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
# not use this file except in compliance with the License. You may obtain
5+
# a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
import sys
16+
import traceback
17+
import unittest
18+
19+
from nova.notifications.objects import exception
20+
from nova import test
21+
22+
23+
class TestExceptionPayload(test.NoDBTestCase):
24+
25+
# Failing due to bug #1881455
26+
@unittest.expectedFailure
27+
def test_from_exc_and_traceback(self):
28+
try:
29+
raise Exception('foo')
30+
except Exception:
31+
exc_info = sys.exc_info()
32+
tb = traceback.format_exc()
33+
34+
payload = exception.ExceptionPayload.from_exc_and_traceback(
35+
exc_info[1], tb)
36+
37+
self.assertEqual(
38+
'nova.tests.unit.notifications.objects.test_exception',
39+
payload.module_name,
40+
)
41+
self.assertEqual(
42+
'test_from_exc_and_traceback', payload.function_name)
43+
self.assertEqual('foo', payload.exception_message)
44+
45+
def test_from_exc_and_traceback_nested(self):
46+
try:
47+
raise Exception('foo')
48+
except Exception:
49+
exc_info = sys.exc_info()
50+
tb = traceback.format_exc()
51+
52+
payload = exception.ExceptionPayload.from_exc_and_traceback(
53+
exc_info[1], tb)
54+
55+
self.assertEqual(
56+
'nova.tests.unit.notifications.objects.test_exception',
57+
payload.module_name,
58+
)
59+
self.assertEqual(
60+
'test_from_exc_and_traceback_nested', payload.function_name)
61+
self.assertEqual('foo', payload.exception_message)

0 commit comments

Comments
 (0)