Skip to content

Commit

Permalink
Basic test for multiple missing scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
Qalthos committed Feb 17, 2025
1 parent 02c26a6 commit 62c4012
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/molecule/scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def sequence(self, scenario_name: str) -> list[str]:
def _verify(self) -> None:
"""Verify the specified scenario was found."""
scenario_names = [c.scenario.name for c in self._configs]
if missing_names := set(self._scenario_names).difference(scenario_names):
if missing_names := sorted(set(self._scenario_names).difference(scenario_names)):
scenario = "Scenario"
if len(missing_names) > 1:
scenario += "s"
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ def test_verify_raises_when_scenario_not_found( # noqa: D103
assert msg in caplog.text


def test_verify_raises_when_multiple_scenarios_not_found( # noqa: D103
_instance: scenarios.Scenarios, # noqa: PT019
caplog: pytest.LogCaptureFixture,
) -> None:
_instance._scenario_names = ["invalid", "also invalid"]
with pytest.raises(SystemExit) as e:
_instance._verify()

assert e.value.code == 1

msg = "Scenarios 'also invalid, invalid' not found. Exiting."
assert msg in caplog.text


def test_filter_for_scenario( # noqa: D103
_instance: scenarios.Scenarios, # noqa: PT019
) -> None:
Expand Down

0 comments on commit 62c4012

Please sign in to comment.