~soren/nova/iptables-security-groups

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/trial/test/suppression.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- test-case-name: twisted.trial.test.test_tests -*-
 
2
# Copyright (c) 2008 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
"""
 
6
Test cases used to make sure that warning supression works at the module,
 
7
method, and class levels.
 
8
"""
 
9
 
 
10
import warnings
 
11
 
 
12
from twisted.trial import unittest, util
 
13
 
 
14
 
 
15
 
 
16
METHOD_WARNING_MSG = "method warning message"
 
17
CLASS_WARNING_MSG = "class warning message"
 
18
MODULE_WARNING_MSG = "module warning message"
 
19
 
 
20
class MethodWarning(Warning):
 
21
    pass
 
22
 
 
23
class ClassWarning(Warning):
 
24
    pass
 
25
 
 
26
class ModuleWarning(Warning):
 
27
    pass
 
28
 
 
29
class EmitMixin:
 
30
    def _emit(self):
 
31
        warnings.warn(METHOD_WARNING_MSG, MethodWarning)
 
32
        warnings.warn(CLASS_WARNING_MSG, ClassWarning)
 
33
        warnings.warn(MODULE_WARNING_MSG, ModuleWarning)
 
34
 
 
35
 
 
36
class TestSuppression(unittest.TestCase, EmitMixin):
 
37
    def testSuppressMethod(self):
 
38
        self._emit()
 
39
    testSuppressMethod.suppress = [util.suppress(message=METHOD_WARNING_MSG)]
 
40
 
 
41
    def testSuppressClass(self):
 
42
        self._emit()
 
43
 
 
44
    def testOverrideSuppressClass(self):
 
45
        self._emit()
 
46
    testOverrideSuppressClass.suppress = []
 
47
 
 
48
TestSuppression.suppress = [util.suppress(message=CLASS_WARNING_MSG)]
 
49
 
 
50
 
 
51
class TestSuppression2(unittest.TestCase, EmitMixin):
 
52
    def testSuppressModule(self):
 
53
        self._emit()
 
54
 
 
55
suppress = [util.suppress(message=MODULE_WARNING_MSG)]
 
56
 
 
57