Skip to content

Commit

Permalink
Pass default selection to wrapped routine (#76)
Browse files Browse the repository at this point in the history
* Set selection to default instead of None
  • Loading branch information
martin-schlipf authored Jan 27, 2023
1 parent 02411f5 commit 0c00d6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/py4vasp/_data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _set_remaining_selection(self, bound_arguments, remaining):
if "selection" not in bound_arguments.arguments:
return bound_arguments
if remaining == [[]]:
selection = None
selection = bound_arguments.signature.parameters["selection"].default
else:
selection = select.selections_to_string(remaining)
bound_arguments.arguments["selection"] = selection
Expand Down
11 changes: 9 additions & 2 deletions tests/data/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class RawData:


RAW_DATA = RawData("example")
DEFAULT_SELECTION = "default_selection"


@pytest.fixture
Expand Down Expand Up @@ -60,7 +61,7 @@ def with_variadic_arguments(self, *args, **kwargs):
return args, kwargs

@base.data_access
def with_selection_argument(self, selection=None):
def with_selection_argument(self, selection=DEFAULT_SELECTION):
return self._raw_data.selection, selection

@base.data_access
Expand Down Expand Up @@ -270,7 +271,13 @@ def test_selection_passed_to_inner_function(mock_access):
def test_missing_selection_argument(mock_access):
example = Example.from_path()
result = example.with_selection_argument()
assert result == (None, None)
assert result == (None, DEFAULT_SELECTION)


def test_only_other_data(mock_access):
example = Example.from_path()
result = example.with_selection_argument(SELECTION)
assert result == (SELECTION, DEFAULT_SELECTION)


def test_selection_of_sources_are_filtered(mock_access):
Expand Down

0 comments on commit 0c00d6e

Please sign in to comment.