-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/3.x-staging' into christophe-pap…
…azian/decouple_appsec_from_tracer
- Loading branch information
Showing
6 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from fastapi import FastAPI | ||
|
||
|
||
def get_app(): | ||
app = FastAPI() | ||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from fastapi.testclient import TestClient | ||
import pytest | ||
|
||
import ddtrace | ||
from ddtrace.contrib.internal.fastapi.patch import patch as fastapi_patch | ||
from ddtrace.contrib.internal.fastapi.patch import unpatch as fastapi_unpatch | ||
from tests.utils import DummyTracer | ||
from tests.utils import TracerSpanContainer | ||
|
||
from . import app | ||
|
||
|
||
@pytest.fixture | ||
def tracer(): | ||
original_tracer = ddtrace.tracer | ||
tracer = DummyTracer() | ||
|
||
ddtrace.tracer = tracer | ||
fastapi_patch() | ||
yield tracer | ||
ddtrace.tracer = original_tracer | ||
fastapi_unpatch() | ||
|
||
|
||
@pytest.fixture | ||
def test_spans(tracer): | ||
container = TracerSpanContainer(tracer) | ||
yield container | ||
container.reset() | ||
|
||
|
||
@pytest.fixture | ||
def fastapi_application(tracer): | ||
application = app.get_app() | ||
yield application | ||
|
||
|
||
@pytest.fixture | ||
def client(tracer, fastapi_application): | ||
with TestClient(fastapi_application) as test_client: | ||
yield test_client |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters