Skip to content

Commit

Permalink
add test case and fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
P403n1x87 committed Aug 16, 2022
1 parent dcaa97d commit 0bf6160
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ddtrace/internal/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def find_module(self, fullname, path=None):
loader = _ImportHookChainedLoader(loader)

if PY2:
# With Python 2 we don't get all the finder invoked, so we
# With Python 2 we don't get all the finders invoked, so we
# make sure we register all the callbacks at the earliest
# opportunity.
for finder in sys.meta_path:
Expand Down
17 changes: 17 additions & 0 deletions tests/internal/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,20 @@ class Bob(BaseCollector):

Bob.uninstall()
Alice.uninstall()


def test_module_watchdog_dict_shallow_copy():
# Save original reference to sys.modules
original_sys_modules = sys.modules

ModuleWatchdog.install()

# Ensure that we have replaced sys.modules
assert original_sys_modules is not sys.modules

# Make a shallow copy of both using the dict constructor
original_modules = set(dict(original_sys_modules).keys())
new_modules = set(dict(sys.modules).keys())

# Ensure that they match
assert original_modules == new_modules

0 comments on commit 0bf6160

Please sign in to comment.