1
# -*- test-case-name: twisted.trial.test.test_tests -*-
2
# Copyright (c) 2008 Twisted Matrix Laboratories.
3
# See LICENSE for details.
6
Test cases used to make sure that warning supression works at the module,
7
method, and class levels.
12
from twisted.trial import unittest, util
16
METHOD_WARNING_MSG = "method warning message"
17
CLASS_WARNING_MSG = "class warning message"
18
MODULE_WARNING_MSG = "module warning message"
20
class MethodWarning(Warning):
23
class ClassWarning(Warning):
26
class ModuleWarning(Warning):
31
warnings.warn(METHOD_WARNING_MSG, MethodWarning)
32
warnings.warn(CLASS_WARNING_MSG, ClassWarning)
33
warnings.warn(MODULE_WARNING_MSG, ModuleWarning)
36
class TestSuppression(unittest.TestCase, EmitMixin):
37
def testSuppressMethod(self):
39
testSuppressMethod.suppress = [util.suppress(message=METHOD_WARNING_MSG)]
41
def testSuppressClass(self):
44
def testOverrideSuppressClass(self):
46
testOverrideSuppressClass.suppress = []
48
TestSuppression.suppress = [util.suppress(message=CLASS_WARNING_MSG)]
51
class TestSuppression2(unittest.TestCase, EmitMixin):
52
def testSuppressModule(self):
55
suppress = [util.suppress(message=MODULE_WARNING_MSG)]