Skip to content

Adding GUI pytest mark #1269

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

Merged
merged 18 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 17 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
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ filterwarnings =
markers =
skip_grpc: skip tests using grpc
corba: skip tests using the CORBA interface
gui: skip tests that launch the GUI interface
testpaths = tests
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def pytest_addoption(parser):
parser.addoption(
"--console", action="store_true", default=False, help="run console tests"
)
parser.addoption("--gui", action="store_true", default=False, help="run GUI tests")
parser.addoption(
"--only-gui", action="store_true", default=False, help="run only GUI tests"
)


def pytest_collection_modifyitems(config, items):
Expand All @@ -148,6 +152,21 @@ def pytest_collection_modifyitems(config, items):
if "skip_grpc" in item.keywords:
item.add_marker(skip_grpc)

only_gui_filter = config.getoption("--only-gui")
if only_gui_filter:
new_items = []
for item in items:
mark = item.get_closest_marker("requires_gui")
if mark and mark.name == "requires_gui":
new_items.append(item)
items[:] = new_items

if not config.getoption("--gui") and not only_gui_filter:
skip_gui = pytest.mark.skip(reason="Requires to launch MAPDL GUI interface.")
for item in items:
if "requires_gui" in item.keywords:
item.add_marker(skip_gui)


@pytest.fixture(scope="session")
def mapdl_console(request):
Expand Down
17 changes: 17 additions & 0 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,20 @@ def test_warn_uncommon_executable_path():
UserWarning, match="does not match the usual ansys executable path style"
):
warn_uncommon_executable_path("")


@pytest.mark.requires_gui
def test_open_gui(mapdl):

mapdl.open_gui()
mapdl.open_gui(include_result=True)
mapdl.open_gui(inplace=True)

mapdl.open_gui(include_result=False)
mapdl.open_gui(inplace=False)

mapdl.open_gui(include_result=True, inplace=False)
mapdl.open_gui(include_result=False, inplace=True)

mapdl.open_gui(include_result=False, inplace=False)
mapdl.open_gui(include_result=True, inplace=True)