Skip to content

Commit 411cbba

Browse files
committed
fix test
1 parent 2576366 commit 411cbba

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

ddtrace/contrib/_valkey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@
6565
# Traces reported for this client will now have "my-custom-queue"
6666
# as the service name.
6767
client.get("my-key")
68-
"""
68+
"""

tests/internal/test_module.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,24 +529,23 @@ def test_module_import_side_effect():
529529

530530

531531
def test_public_modules_in_ddtrace_contrib():
532-
# Ensures that public modules are not accidentally added to the integration API
532+
# Ensures that public modules are not accidentally added to ddtrace.contrib
533533
contrib_dir = Path(DDTRACE_PATH) / "ddtrace" / "contrib"
534534

535535
public_modules = set()
536536
for directory, _, file_names in os.walk(contrib_dir):
537537
relative_dir = Path(directory).relative_to(contrib_dir)
538-
if "internal" in relative_dir.parts or any([x.startswith("_") for x in relative_dir.parts]):
538+
if "internal" in relative_dir.parts:
539+
# ignore modules in ddtrace/contrib/internal
539540
continue
540541

541-
# Open files in ddtrace/contrib/ and check if the content matches the template
542542
for file_name in file_names:
543-
# Skip internal and __init__ modules, as they are not supposed to have the deprecation template
544-
if file_name.endswith(".py") and not (file_name.startswith("_") or file_name == "__init__.py"):
545-
# Get the relative path of the file from ddtrace/contrib to the deprecated file (ex: pymongo/patch)
546-
relative_dir_with_file = relative_dir / file_name[:-3] # Remove the .py extension
547-
# Convert the relative path to python module format (ex: [pymongo, patch] -> pymongo.patch)
548-
sub_modules = ".".join(relative_dir_with_file.parts)
549-
public_modules.add(f"ddtrace.contrib.{sub_modules}")
543+
# Ignore private modules (python files prefixed with "_")
544+
if file_name.endswith(".py") and not file_name.startswith("_"):
545+
# Covert filename to a module name (ex: dd-trace-py/ddtrace/contrib/flask.py -> ddtrace.contrib.flask)
546+
relative_dir_with_file = relative_dir / file_name[:-3]
547+
module_name = "ddtrace.contrib." + ".".join(relative_dir_with_file.parts)
548+
public_modules.add(module_name)
550549

551550
# The following modules contain attributes that are exposed to ddtrace users. All other modules in ddtrace.contrib
552551
# are internal.

0 commit comments

Comments
 (0)