Skip to content

Commit 8335301

Browse files
test: Remove test_installed_modules
The test `test_installed_modules` appears to not be all that useful. The test exists to verify the behavior of the [`_generate_installed_modules` function](https://github.com/getsentry/sentry-python/blob/9b66f3b51502ca600554c711bc3f599c18f8f18b/sentry_sdk/utils.py#L1689). However, all the test does is essentially check the output of `_generate_installed_modules` against a refactored version of the function call itself. In short, in its current form, the test appears to not make too much sense. As the test recently started failing, let's just delete it.
1 parent 9b66f3b commit 8335301

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

tests/test_utils.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
serialize_frame,
3131
is_sentry_url,
3232
_get_installed_modules,
33-
_generate_installed_modules,
3433
ensure_integration_enabled,
3534
to_string,
3635
exc_info_from_error,
@@ -667,47 +666,6 @@ def __str__(self):
667666
assert result == repr(obj)
668667

669668

670-
def test_installed_modules():
671-
try:
672-
from importlib.metadata import distributions, version
673-
674-
importlib_available = True
675-
except ImportError:
676-
importlib_available = False
677-
678-
try:
679-
import pkg_resources
680-
681-
pkg_resources_available = True
682-
except ImportError:
683-
pkg_resources_available = False
684-
685-
installed_distributions = {
686-
_normalize_distribution_name(dist): version
687-
for dist, version in _generate_installed_modules()
688-
}
689-
690-
if importlib_available:
691-
importlib_distributions = {
692-
_normalize_distribution_name(dist.metadata.get("Name", None)): version(
693-
dist.metadata.get("Name", None)
694-
)
695-
for dist in distributions()
696-
if dist.metadata.get("Name", None) is not None
697-
and version(dist.metadata.get("Name", None)) is not None
698-
}
699-
assert installed_distributions == importlib_distributions
700-
701-
elif pkg_resources_available:
702-
pkg_resources_distributions = {
703-
_normalize_distribution_name(dist.key): dist.version
704-
for dist in pkg_resources.working_set
705-
}
706-
assert installed_distributions == pkg_resources_distributions
707-
else:
708-
pytest.fail("Neither importlib nor pkg_resources is available")
709-
710-
711669
def test_installed_modules_caching():
712670
mock_generate_installed_modules = mock.Mock()
713671
mock_generate_installed_modules.return_value = {"package": "1.0.0"}

0 commit comments

Comments
 (0)