~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:20:33 UTC
  • mto: This revision was merged to the branch mainline in revision 3458.
  • Revision ID: john@arbash-meinel.com-20080528232033-cx3l3yg845udklps
Bring back always in the form of 'override'.
Change the functions so that they are compatible with the released
definition, and just allow callers to supply override=False
if they want the new behavior.

Show diffs side-by-side

added added

removed removed

Lines of Context:
233
233
 
234
234
    def test_suppress_deprecation_with_warning_filter(self):
235
235
        """don't suppress if we already have a filter"""
236
 
        warnings.filterwarnings('ignore', category=Warning)
237
 
        self.assertFirstWarning('ignore', Warning)
 
236
        warnings.filterwarnings('error', category=Warning)
 
237
        self.assertFirstWarning('error', Warning)
238
238
        self.assertEqual(1, len(warnings.filters))
239
 
        symbol_versioning.suppress_deprecation_warnings()
240
 
        self.assertFirstWarning('ignore', Warning)
 
239
        symbol_versioning.suppress_deprecation_warnings(override=False)
 
240
        self.assertFirstWarning('error', Warning)
241
241
        self.assertEqual(1, len(warnings.filters))
242
242
 
243
243
    def test_suppress_deprecation_with_filter(self):
244
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))
 
245
        warnings.filterwarnings('error', category=DeprecationWarning)
 
246
        self.assertFirstWarning('error', DeprecationWarning)
 
247
        self.assertEqual(1, len(warnings.filters))
 
248
        symbol_versioning.suppress_deprecation_warnings(override=False)
 
249
        self.assertFirstWarning('error', DeprecationWarning)
 
250
        self.assertEqual(1, len(warnings.filters))
 
251
        symbol_versioning.suppress_deprecation_warnings(override=True)
 
252
        self.assertFirstWarning('ignore', DeprecationWarning)
 
253
        self.assertEqual(2, len(warnings.filters))
251
254
 
252
255
    def test_activate_deprecation_no_error(self):
253
256
        # First nuke the filters, so we know it is clean
260
263
        warnings.filterwarnings('error', category=Warning)
261
264
        self.assertFirstWarning('error', Warning)
262
265
        self.assertEqual(1, len(warnings.filters))
263
 
        symbol_versioning.activate_deprecation_warnings()
 
266
        symbol_versioning.activate_deprecation_warnings(override=False)
264
267
        # There should not be a new warning
265
268
        self.assertFirstWarning('error', Warning)
266
269
        self.assertEqual(1, len(warnings.filters))
271
274
        warnings.filterwarnings('error', category=DeprecationWarning)
272
275
        self.assertFirstWarning('error', DeprecationWarning)
273
276
        self.assertEqual(1, len(warnings.filters))
274
 
        symbol_versioning.activate_deprecation_warnings()
 
277
        symbol_versioning.activate_deprecation_warnings(override=False)
275
278
        # There should not be a new warning
276
279
        self.assertFirstWarning('error', DeprecationWarning)
277
280
        self.assertEqual(1, len(warnings.filters))
 
281
        symbol_versioning.activate_deprecation_warnings(override=True)
 
282
        self.assertFirstWarning('default', DeprecationWarning)
 
283
        self.assertEqual(2, len(warnings.filters))