Skip to content
Closed
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
28 changes: 28 additions & 0 deletions general/g.list/tests/g_list_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

import grass.script as gs
from grass.exceptions import CalledModuleError
from grass.tools import Tools


Expand Down Expand Up @@ -176,6 +177,24 @@
assert actual == plain_actual


@pytest.mark.parametrize(
("flags", "message_parts"),
[
("pt", ["-p", "-t"]),
("ft", ["-f", "-t"]),
("pf", ["-p", "-f"]),
("re", ["-r", "-e"]),
],
)
def test_exclusive_flags(simple_dataset, flags, message_parts):
"""Test that mutually exclusive flags for g.list fail with CalledModuleError."""
with pytest.raises(CalledModuleError) as excinfo:
gs.run_command("g.list", flags=flags, type="raster", env=simple_dataset.env)

for part in message_parts:
assert part in excinfo.value.errors

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_exclusive_flags[re-message_parts3] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_exclusive_flags[re-message_parts3] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_exclusive_flags[pf-message_parts2] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_exclusive_flags[pf-message_parts2] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_exclusive_flags[ft-message_parts1] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_exclusive_flags[ft-message_parts1] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_exclusive_flags[pt-message_parts0] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_exclusive_flags[pt-message_parts0] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_exclusive_flags[re-message_parts3] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_exclusive_flags[re-message_parts3] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_exclusive_flags[pf-message_parts2] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_exclusive_flags[pf-message_parts2] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_exclusive_flags[ft-message_parts1] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_exclusive_flags[ft-message_parts1] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_exclusive_flags[pt-message_parts0] TypeError: argument of type 'NoneType' is not iterable

Check failure on line 195 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_exclusive_flags[pt-message_parts0] TypeError: argument of type 'NoneType' is not iterable


@pytest.mark.xfail(
sys.platform == "win32",
reason="map titles are not listed",
Expand Down Expand Up @@ -305,3 +324,12 @@
)
assert not result
assert list(result) == []


def test_invalid_format_combination(simple_dataset):
"""Test that invalid format combinations fail with CalledModuleError."""
with pytest.raises(CalledModuleError) as excinfo:
gs.run_command(
"g.list", type="raster", format="plain", flags="t", env=simple_dataset.env
)
assert "format=plain" in excinfo.value.errors

Check failure on line 335 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_invalid_format_combination TypeError: argument of type 'NoneType' is not iterable

Check failure on line 335 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / macOS build

test_invalid_format_combination TypeError: argument of type 'NoneType' is not iterable

Check failure on line 335 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_invalid_format_combination TypeError: argument of type 'NoneType' is not iterable

Check failure on line 335 in general/g.list/tests/g_list_test.py

View workflow job for this annotation

GitHub Actions / pytest (ubuntu-24.04, 3.10)

test_invalid_format_combination TypeError: argument of type 'NoneType' is not iterable
Loading