Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scripts/sync_test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"gc",
"glob",
"hashlib",
"html",
"http",
"importlib",
"inspect",
"io",
Expand All @@ -72,6 +74,8 @@
"random",
"re",
"runpy",
"email",
"secrets",
"shlex",
"shutil",
"signal",
Expand Down Expand Up @@ -105,6 +109,8 @@
"traceback",
"pprint",
}
if hasattr(sys, "stdlib_module_names"):
STDLIB_MODULES.update(sys.stdlib_module_names)

# Known test framework modules
TEST_FRAMEWORK_MODULES = {
Expand Down Expand Up @@ -221,6 +227,7 @@ def get_project_modules() -> set[str]:

# Module name to package name mappings for known exceptions
MODULE_TO_PACKAGE = {
"jwt": "PyJWT",
"yaml": "PyYAML",
"PIL": "Pillow",
"sklearn": "scikit-learn",
Expand Down
7 changes: 7 additions & 0 deletions templates/consumer-repo/scripts/sync_test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"gc",
"glob",
"hashlib",
"html",
"http",
"importlib",
"inspect",
"io",
Expand All @@ -72,6 +74,8 @@
"random",
"re",
"runpy",
"email",
"secrets",
"shlex",
"shutil",
"signal",
Expand Down Expand Up @@ -104,6 +108,8 @@
"traceback",
"pprint",
}
if hasattr(sys, "stdlib_module_names"):
STDLIB_MODULES.update(sys.stdlib_module_names)

# Known test framework modules
TEST_FRAMEWORK_MODULES = {
Expand Down Expand Up @@ -220,6 +226,7 @@ def get_project_modules() -> set[str]:

# Module name to package name mappings for known exceptions
MODULE_TO_PACKAGE = {
"jwt": "PyJWT",
"yaml": "PyYAML",
"PIL": "Pillow",
"sklearn": "scikit-learn",
Expand Down
20 changes: 20 additions & 0 deletions tests/scripts/test_sync_test_dependencies_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_pptx_maps_to_python_pptx_in_repo_script():
)

assert module.MODULE_TO_PACKAGE["pptx"] == "python-pptx"
assert module.MODULE_TO_PACKAGE["jwt"] == "PyJWT"


def test_pptx_maps_to_python_pptx_in_consumer_template():
Expand All @@ -29,3 +30,22 @@ def test_pptx_maps_to_python_pptx_in_consumer_template():
)

assert module.MODULE_TO_PACKAGE["pptx"] == "python-pptx"
assert module.MODULE_TO_PACKAGE["jwt"] == "PyJWT"


def test_stdlib_imports_from_sync_pr_logs_are_ignored_in_repo_script():
module = _load_module(
"sync_test_dependencies_repo_stdlib",
Path("scripts/sync_test_dependencies.py"),
)

assert {"email", "html", "http", "secrets"}.issubset(module.STDLIB_MODULES)


def test_stdlib_imports_from_sync_pr_logs_are_ignored_in_consumer_template():
module = _load_module(
"sync_test_dependencies_consumer_template_stdlib",
Path("templates/consumer-repo/scripts/sync_test_dependencies.py"),
)

assert {"email", "html", "http", "secrets"}.issubset(module.STDLIB_MODULES)
Loading