def setUp(self): patch() self.tracer = get_dummy_tracer() self.app = flask.Flask(__name__, template_folder='test_templates/') self.client = self.app.test_client() Pin.override(self.app, tracer=self.tracer)
def setUp(self): super(BaseFlaskTestCase, self).setUp() patch() self.app = flask.Flask(__name__, template_folder="test_templates/") self.client = self.app.test_client() Pin.override(self.app, tracer=self.tracer)
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_patch_idempotency(self, _w): # Ensure we didn't do any patching automatically _w.assert_not_called() self.assert_is_not_patched() # Patch for the first time patch() _w.assert_called() self.assert_is_patched() # Reset the mock so we can assert call count _w.reset_mock() # Call patch a second time patch() _w.assert_not_called() self.assert_is_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()