refactor root directory detection to be cleaner

This commit is contained in:
Lincoln Stein
2023-07-31 22:27:07 -04:00
parent 7cd8b2f207
commit 72ebe2ce68
2 changed files with 16 additions and 2 deletions

View File

@ -84,6 +84,20 @@ def test_env_override():
assert conf.max_cache_size == 20
def test_root_resists_cwd():
previous = os.environ["INVOKEAI_ROOT"]
cwd = Path(os.getcwd()).resolve()
os.environ["INVOKEAI_ROOT"] = "."
conf = InvokeAIAppConfig.get_config()
conf.parse_args([])
assert conf.root_path == cwd
os.chdir(previous)
assert conf.root_path == cwd
os.environ["INVOKEAI_ROOT"] = previous
def test_type_coercion():
conf = InvokeAIAppConfig().get_config()
conf.parse_args(argv=["--root=/tmp/foobar"])