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

Making cas_project expected name of module that defines project. #147

Merged
merged 2 commits into from
Aug 21, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cassini/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def find_project(import_string=None):

path/to/module:project_obj

By default, `project_obj` is assumed to be called `project`. This will be imported from `module`.
By default, `project_obj` is assumed to be called `project`. This will be imported from `module`, which by default is
assumed to be `cas_project`.

Note that for cassini to run with a regular jupyterlab instance, `ContentsManager.allow_hidden = True` must be set, either
via a config, or passed as a command line argument e.g. `--ContentsManager.allow_hidden=True`
Expand Down Expand Up @@ -232,7 +233,7 @@ def find_project(import_string=None):
obj = "project"
elif path.is_dir():
directory = path.as_posix()
module = "project"
module = "cas_project"
obj = "project"
else:
raise RuntimeError(f"Cannot parse CASSINI_PROJECT {CASSINI_PROJECT}")
Expand Down
12 changes: 6 additions & 6 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def wrapped():
Project._instance = None
env.project = None

if 'project' in sys.modules:
del sys.modules['project']
if 'cas_project' in sys.modules:
del sys.modules['cas_project']
if 'my_project' in sys.modules:
del sys.modules['my_project']

Expand All @@ -33,7 +33,7 @@ def wrapped():


def test_find_not_set(tmp_path, refresh_project):
project = shutil.copy('tests/project_cases/basic.py', tmp_path / 'project.py')
project = shutil.copy('tests/project_cases/basic.py', tmp_path / 'cas_project.py')

refresh_project()

Expand All @@ -49,7 +49,7 @@ def test_find_not_set(tmp_path, refresh_project):
itertools.product(
['basic.py', 'not_project.py'],
['', 'subdir'],
['project.py', 'my_project.py'],
['cas_project.py', 'my_project.py'],
['{module}', '{module_file}', '{directory}'],
['', ':{project_obj}'],
[False, True]
Expand All @@ -63,8 +63,8 @@ def cas_project(request, tmp_path, refresh_project):
if obj_format == ':{project_obj}' and module_format == '{directory}':
return pytest.skip("Valid CASSINI_PATH cannot be constructed from directory and object specifier")

if module_format == '{directory}' and project_out != 'project.py':
return pytest.skip("Valid CASSINI_PATH cannot be constructed from directory if project not called project.py")
if module_format == '{directory}' and project_out != 'cas_project.py':
return pytest.skip("Valid CASSINI_PATH cannot be constructed from directory if project not called cas_project.py")

if module_format == '{module}' and subdir:
return pytest.skip("Valid CASSINI_PATH cannot be constructed from just module if it's inside a subdir")
Expand Down
Loading