/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Andrew Bennetts
  • Date: 2007-10-26 07:25:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2946.
  • Revision ID: andrew.bennetts@canonical.com-20071026072544-1c9p65ogzvtb61ay
Override warnings.filters in callCatchWarnings, to insulate it from -Werror.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1101
1101
 
1102
1102
        :returns: ([warning_object, ...], fn_result)
1103
1103
        """
1104
 
        # XXX: This is not perfect, because it doesn't override the warnings
1105
 
        # filters, and they'll often want to show a warning only once per
1106
 
        # source origin.  That might be a problem for repeated tests of
1107
 
        # similar situations.  -- mbp 20071024
 
1104
        # XXX: This is not perfect, because it completely overrides the
 
1105
        # warnings filters, and some code may depend on suppressing particular
 
1106
        # warnings.  It's the easiest way to insulate ourselves from -Werror,
 
1107
        # though.  -- Andrew, 20071062
1108
1108
        wlist = []
1109
1109
        def _catcher(message, category, filename, lineno, file=None):
1110
1110
            # despite the name, 'message' is normally(?) a Warning subclass
1111
1111
            # instance
1112
1112
            wlist.append(message)
1113
1113
        saved_showwarning = warnings.showwarning
 
1114
        saved_filters = warnings.filters
1114
1115
        try:
1115
1116
            warnings.showwarning = _catcher
 
1117
            warnings.filters = []
1116
1118
            result = fn(*args, **kw)
1117
1119
        finally:
1118
1120
            warnings.showwarning = saved_showwarning
 
1121
            warnings.filters = saved_filters
1119
1122
        return wlist, result
1120
1123
 
1121
1124
    def callDeprecated(self, expected, callable, *args, **kwargs):