- 移除 _DEFAULT_INPUT 硬编码默认输入文件路径 - INPUT_JSON 仅从 IR_INPUT_JSON 环境变量获取 - load_input_document() 无输入时给出明确错误提示 - 新增 test_no_hardcoded_input_file / test_set_input_file_accepts_none Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,33 @@ def test_set_input_file():
|
||||
config.set_input_file(original)
|
||||
|
||||
|
||||
def test_no_hardcoded_input_file():
|
||||
"""INPUT_JSON should not have a hardcoded default — comes from env or None."""
|
||||
# When IR_INPUT_JSON env is not set, INPUT_JSON should be None
|
||||
env_val = os.environ.pop("IR_INPUT_JSON", None)
|
||||
try:
|
||||
import importlib
|
||||
importlib.reload(config)
|
||||
# After reload without env var, INPUT_JSON should be None
|
||||
assert config.INPUT_JSON is None, \
|
||||
f"INPUT_JSON should be None when env not set, got: {config.INPUT_JSON}"
|
||||
finally:
|
||||
if env_val is not None:
|
||||
os.environ["IR_INPUT_JSON"] = env_val
|
||||
importlib.reload(config)
|
||||
|
||||
|
||||
def test_set_input_file_accepts_none():
|
||||
"""set_input_file(None) should work for resetting."""
|
||||
original = config.INPUT_JSON
|
||||
try:
|
||||
config.set_input_file("/tmp/test.json")
|
||||
config.set_input_file(None)
|
||||
assert config.INPUT_JSON is None
|
||||
finally:
|
||||
config.set_input_file(original)
|
||||
|
||||
|
||||
def test_config_constants_exist():
|
||||
"""Verify all expected path constants are defined."""
|
||||
assert config.BASE_DIR
|
||||
|
||||
Reference in New Issue
Block a user