Skip to content

Commit

Permalink
clarified comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianlim committed Jul 25, 2024
1 parent 748595c commit 9438aba
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugins/framework/tests/test_model_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,21 +336,26 @@ def patched_mod_function():
# S3.2 - module1.module3.module3_1 is a submodule of module1
# 1. Replace module1.module3.module3_1.Module3Class with a new class
# 2. reload the top-level module path module1
# -> NOTE: in general, we should avoid targeting any parent paths
# for reload
with isolate_test_module_fixtures():
patch_target_module(
"tests.model_patcher_fixtures.module1.module3.module3_1.Module3Class",
PatchedModuleClass,
"tests.model_patcher_fixtures.module1",
)

# - the reload of the top level module path module1, will replace module1.module3
# - the reload of the top level module path module1, will NOT replace module1.module3
# with the original version
# - reloading top-level paths is tricky due to caching of the modules
# - the reload of a top-level module does not cascade down to children modules.
assert not isinstance(module1.module3.module3_1.Module3Class(), PatchedModuleClass)
assert not isinstance(module1.module3.Module3Class(), PatchedModuleClass)

# S3.3 - module1.module3 is a submodule of module1
# 1. Replace module1.module3.module3_1.Module3Class with a new class
# 2. reload the top-level module path module1
# -> NOTE: in general, we should avoid targeting any parent paths
# for reload
with isolate_test_module_fixtures():
patch_target_module(
"tests.model_patcher_fixtures.module1.module3.Module3Class",
Expand All @@ -361,7 +366,6 @@ def patched_mod_function():
# - the reload of the top level module path module1, will replace module1.module3
# with the original version
assert not isinstance(module1.module3.module3_1.Module3Class(), PatchedModuleClass)
assert not isinstance(module1.module3.Module3Class(), PatchedModuleClass)

# S4 - module1.module3 submodule has a dependency on
# module1.module1_1.mod_1_function
Expand Down

0 comments on commit 9438aba

Please sign in to comment.