Skip to content

Commit

Permalink
Force reimport of modules during serverless test.
Browse files Browse the repository at this point in the history
  • Loading branch information
purple4reina committed Jan 9, 2025
1 parent 04ee68f commit 07c753d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/internal/test_serverless.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import mock
import pytest

from ddtrace.internal.serverless import in_azure_function
from ddtrace.internal.serverless import in_gcp_function
Expand Down Expand Up @@ -78,6 +79,7 @@ def test_not_azure_function_consumption_plan():
assert in_azure_function() is False


@pytest.mark.subprocess()
def test_slow_imports():
# We should lazy load certain modules to avoid slowing down the startup
# time when running in a serverless environment. This test will fail if
Expand Down Expand Up @@ -115,6 +117,10 @@ def find_spec(self, fullname, *args):
try:
sys.meta_path.insert(0, BlockListFinder())

for mod in sys.modules.copy():
if mod in blocklist or mod.startswith("ddtrace"):
del sys.modules[mod]

import ddtrace
import ddtrace.contrib.aws_lambda # noqa:F401
import ddtrace.contrib.psycopg # noqa:F401
Expand Down

0 comments on commit 07c753d

Please sign in to comment.