~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_symbol_versioning.py

  • Committer: John Arbash Meinel
  • Date: 2008-05-28 23:08:34 UTC
  • mto: This revision was merged to the branch mainline in revision 3458.
  • Revision ID: john@arbash-meinel.com-20080528230834-m1qw9peoydd3koty
Disable suppression if there is already a filter present for Warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
218
218
        def restore():
219
219
            warnings.filters[:] = existing_filters
220
220
        self.addCleanup(restore)
 
221
        # Clean out the filters so we have a clean slate.
 
222
        warnings.resetwarnings()
221
223
 
222
224
    def assertFirstWarning(self, action, category):
223
225
        """Test the first warning in the filters is correct"""
229
231
        symbol_versioning.suppress_deprecation_warnings()
230
232
        self.assertFirstWarning('ignore', DeprecationWarning)
231
233
 
 
234
    def test_suppress_deprecation_with_warning_filter(self):
 
235
        """don't suppress if we already have a filter"""
 
236
        warnings.filterwarnings('ignore', category=Warning)
 
237
        self.assertFirstWarning('ignore', Warning)
 
238
        self.assertEqual(1, len(warnings.filters))
 
239
        symbol_versioning.suppress_deprecation_warnings()
 
240
        self.assertFirstWarning('ignore', Warning)
 
241
        self.assertEqual(1, len(warnings.filters))
 
242
 
 
243
    def test_suppress_deprecation_with_filter(self):
 
244
        """don't suppress if we already have a filter"""
 
245
        warnings.filterwarnings('ignore', category=DeprecationWarning)
 
246
        self.assertFirstWarning('ignore', DeprecationWarning)
 
247
        self.assertEqual(1, len(warnings.filters))
 
248
        symbol_versioning.suppress_deprecation_warnings()
 
249
        self.assertFirstWarning('ignore', DeprecationWarning)
 
250
        self.assertEqual(1, len(warnings.filters))
 
251
 
232
252
    def test_activate_deprecation_warnings(self):
233
253
        symbol_versioning.activate_deprecation_warnings(always=True)
234
254
        self.assertFirstWarning('default', DeprecationWarning)
235
255
 
236
256
    def test_activate_deprecation_no_error(self):
237
257
        # First nuke the filters, so we know it is clean
238
 
        warnings.resetwarnings()
239
258
        symbol_versioning.activate_deprecation_warnings(always=False)
240
259
        self.assertFirstWarning('default', DeprecationWarning)
241
260
 
242
261
    def test_activate_deprecation_with_error(self):
243
262
        # First nuke the filters, so we know it is clean
244
 
        warnings.resetwarnings()
245
263
        # Add a warning == error rule
246
264
        warnings.filterwarnings('error', category=Warning)
247
265
        self.assertFirstWarning('error', Warning)
253
271
 
254
272
    def test_activate_deprecation_with_DW_error(self):
255
273
        # First nuke the filters, so we know it is clean
256
 
        warnings.resetwarnings()
257
274
        # Add a warning == error rule
258
275
        warnings.filterwarnings('error', category=DeprecationWarning)
259
276
        self.assertFirstWarning('error', DeprecationWarning)