Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix load_config failure in command and repl use #73

Merged
merged 4 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions ballet/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def load_config(path: Optional[Pathy] = None, ascend: bool = True) -> Dynaconf:
finally:
del frame

if path in ('<stdin>', '<string>'):
path = pathlib.Path.cwd()

path = pathlib.Path(path)
while path.exists() and not is_mount(path):
try:
Expand Down
15 changes: 15 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pathlib
import random
import shlex
import subprocess
import sys
from unittest.mock import ANY, PropertyMock, patch

Expand All @@ -24,6 +26,19 @@ def test_load_config_detect(mock_load_config_in_dir):
mock_load_config_in_dir.assert_called_once_with(path)


@pytest.mark.skipif(
sys.version_info < (3, 7),
reason='capture_output added in py37, not worth it to add compat')
@patch('ballet.project.load_config_in_dir')
def test_load_config_dash_c(mock_load_config_in_dir, quickstart):
# note that this tests python -c 'cmd' which is different from the repl!
pycmd = 'from ballet.project import load_config; config=load_config()'
cmd = f"{sys.executable} -c '{pycmd}'"
result = subprocess.run(
shlex.split(cmd), cwd=quickstart.project.path, capture_output=True)
assert not result.returncode, result.stderr


@pytest.mark.xfail
def test_load_config_at_path():
raise NotImplementedError
Expand Down