def test_unpatch(self): """ When we unpatch Flask Then ``flask.render_template`` is unpatched Then ``flask.render_template_string`` is unpatched Then ``flask.templating._render`` is unpatched """ unpatch() self.assert_is_not_wrapped(flask.render_template) self.assert_is_not_wrapped(flask.render_template_string) self.assert_is_not_wrapped(flask.templating._render)
def test_unpatch(self): """ When the signals are unpatched Their ``receivers_for`` method is not a ``wrapt.ObjectProxy`` """ unpatch() for signal_name in self.signals(): signal = self.get_signal(signal_name) receivers_for = getattr(signal, "receivers_for") self.assert_is_not_wrapped(receivers_for)
def test_datadog_patch(self): # If we have been patching/testing in other files, # at least make sure this is where we want it if hasattr(flask, "_datadog_patch"): self.assertFalse(flask._datadog_patch) # Patching sets `_datadog_patch` to `True` patch() self.assert_is_patched() # Unpatching sets `_datadog_patch` to `False` unpatch() self.assert_is_not_patched()
def test_unpatch_idempotency(self, _u, _w): # We need to patch in order to unpatch patch() _w.assert_called() self.assert_is_patched() # Ensure we didn't do any unpatching automatically _u.assert_not_called() unpatch() _u.assert_called() self.assert_is_not_patched() # Reset the mock so we can assert call count _u.reset_mock() # Call unpatch a second time unpatch() _u.assert_not_called() self.assert_is_not_patched()
def tearDown(self): # Remove any remaining spans self.tracer.writer.pop() # Unpatch Flask unpatch()
def tearDown(self): # Double check we unpatch after every test unpatch()
def tearDown(self): super(BaseFlaskTestCase, self).tearDown() # Unpatch Flask unpatch()