def test_patch(self): """ Confirm patching was successful """ log = logging.getLogger() self.assertTrue(isinstance(log.makeRecord, wrapt.BoundFunctionWrapper)) # For Python 3 if hasattr(logging, "StrFormatStyle"): if hasattr(logging.StrFormatStyle, "_format"): assert isinstance(logging.StrFormatStyle._format, wrapt.BoundFunctionWrapper) else: assert isinstance(logging.StrFormatStyle.format, wrapt.BoundFunctionWrapper) unpatch() log = logging.getLogger() self.assertFalse(isinstance(log.makeRecord, wrapt.BoundFunctionWrapper)) # For Python 3 if hasattr(logging, "StrFormatStyle"): if hasattr(logging.StrFormatStyle, "_format"): assert not isinstance(logging.StrFormatStyle._format, wrapt.BoundFunctionWrapper) else: assert not isinstance(logging.StrFormatStyle.format, wrapt.BoundFunctionWrapper)
def test_patch(self): """ Confirm patching was successful """ log = logging.getLogger() self.assertTrue(isinstance(log.makeRecord, wrapt.BoundFunctionWrapper)) unpatch() log = logging.getLogger() self.assertFalse(isinstance(log.makeRecord, wrapt.BoundFunctionWrapper))
def tearDown(self): unpatch() super(LoggingTestCase, self).tearDown()