41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
"""
|
|
Tiny tests to verify module aliasing behavior between 'src.*' and top-level
|
|
modules for compatibility with test patching.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import importlib
|
|
|
|
|
|
# Ensure 'src' is importable like other tests do
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
|
|
|
|
|
def test_graph_manager_aliasing_shared_module_object():
|
|
import src.graph_manager as gm_src
|
|
|
|
gm_top = importlib.import_module("graph_manager")
|
|
|
|
# Both import paths should refer to the same module object
|
|
assert gm_src is gm_top
|
|
|
|
# Patching a symbol on one should reflect in the other
|
|
sentinel = object()
|
|
setattr(gm_top, "ALIAS_TEST_SENTINEL", sentinel)
|
|
assert getattr(gm_src, "ALIAS_TEST_SENTINEL") is sentinel
|
|
|
|
|
|
def test_logger_aliasing_shared_module_object():
|
|
import src.logger as logger_src
|
|
|
|
logger_top = importlib.import_module("logger")
|
|
|
|
# Both import paths should refer to the same module object
|
|
assert logger_src is logger_top
|
|
|
|
# Changing a config attribute should be visible via the other name
|
|
new_path = "/tmp/thechart-test-alias"
|
|
logger_top.LOG_PATH = new_path
|
|
assert logger_src.LOG_PATH == new_path
|