Skip to content

Commit f2e011b

Browse files
germa89akaszynski
andauthored
Adding GUI pytest mark (#1269)
* Implement the option to run inplace. Using original jobname. * Making sure the start_parameter is updated and stored. * Added MAPDLdidnotstart exception class. * Using new error class. * Updated docstring. * removing error classes. * small fix. * Making sure there is no edge cases in args * Fixing coverage and adding unit tests to error classes. * Updating docstrings * Added '--gui' and '--only_gui' command line options * Adding function to test. * Adding unit test and changing flag option * fixing static * Update tests/test_launcher.py Co-authored-by: Alex Kaszynski <[email protected]>
1 parent 39402d2 commit f2e011b

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ filterwarnings =
1111
markers =
1212
skip_grpc: skip tests using grpc
1313
corba: skip tests using the CORBA interface
14+
gui: skip tests that launch the GUI interface
1415
testpaths = tests

tests/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ def pytest_addoption(parser):
125125
parser.addoption(
126126
"--console", action="store_true", default=False, help="run console tests"
127127
)
128+
parser.addoption("--gui", action="store_true", default=False, help="run GUI tests")
129+
parser.addoption(
130+
"--only-gui", action="store_true", default=False, help="run only GUI tests"
131+
)
128132

129133

130134
def pytest_collection_modifyitems(config, items):
@@ -148,6 +152,21 @@ def pytest_collection_modifyitems(config, items):
148152
if "skip_grpc" in item.keywords:
149153
item.add_marker(skip_grpc)
150154

155+
only_gui_filter = config.getoption("--only-gui")
156+
if only_gui_filter:
157+
new_items = []
158+
for item in items:
159+
mark = item.get_closest_marker("requires_gui")
160+
if mark and mark.name == "requires_gui":
161+
new_items.append(item)
162+
items[:] = new_items
163+
164+
if not config.getoption("--gui") and not only_gui_filter:
165+
skip_gui = pytest.mark.skip(reason="Requires to launch MAPDL GUI interface.")
166+
for item in items:
167+
if "requires_gui" in item.keywords:
168+
item.add_marker(skip_gui)
169+
151170

152171
@pytest.fixture(scope="session")
153172
def mapdl_console(request):

tests/test_launcher.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,20 @@ def test_warn_uncommon_executable_path():
299299
UserWarning, match="does not match the usual ansys executable path style"
300300
):
301301
warn_uncommon_executable_path("")
302+
303+
304+
@pytest.mark.requires_gui
305+
def test_open_gui(mapdl):
306+
307+
mapdl.open_gui()
308+
mapdl.open_gui(include_result=True)
309+
mapdl.open_gui(inplace=True)
310+
311+
mapdl.open_gui(include_result=False)
312+
mapdl.open_gui(inplace=False)
313+
314+
mapdl.open_gui(include_result=True, inplace=False)
315+
mapdl.open_gui(include_result=False, inplace=True)
316+
317+
mapdl.open_gui(include_result=False, inplace=False)
318+
mapdl.open_gui(include_result=True, inplace=True)

0 commit comments

Comments
 (0)