Skip to content

Commit

Permalink
test(all): Run tests with a timeout
Browse files Browse the repository at this point in the history
The default timeout is 10s, single tests that usually run longer have a
custom timeout.

See https://pypi.org/project/pytest-timeout/ for more details
  • Loading branch information
franzlst committed Mar 6, 2019
1 parent 0430db6 commit 727f671
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
addopts = -x -p no:pytest_capturelog
testpaths = tests
norecursedirs = .git all source share doc
timeout = 10
timeout_method = thread
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def run(self):
global_requirements = ['pylint>=1.6,<2', 'pyyaml~=3.10', 'psutil', 'jsonconversion~=0.2.9', 'yaml_configuration~=0.1',
'python-gtkmvc3-dlr~=1.0.0', 'gaphas~=1.0.0rc1', 'future>=0.16,<0.18.0']

test_requirements = ['pytest', 'pytest-catchlog', 'graphviz', 'pyuserinput'] + global_requirements
test_requirements = ['pytest', 'pytest-timeout', 'pytest-catchlog', 'graphviz', 'pyuserinput'] + global_requirements

setup(
name='rafcon',
Expand Down
2 changes: 2 additions & 0 deletions tests/gui/test__destruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time
import shutil
import gtkmvc3
import pytest

from pprint import pprint

Expand Down Expand Up @@ -998,6 +999,7 @@ def test_simple_execution_model_and_core_destruct_with_gui(caplog):
gui_config={'AUTO_BACKUP_ENABLED': False, 'HISTORY_ENABLED': False})


@pytest.mark.timeout(60)
def test_model_and_core_modification_history_destruct_with_gui(caplog):
testing_utils.dummy_gui(None)

Expand Down
1 change: 1 addition & 0 deletions tests/gui/test_group_ungroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def trigger_issue_586_reproduction_sequence():
# call_gui_callback(sm_m.history.undo)


@pytest.mark.timeout(20)
def test_bug_issue_586(caplog):
testing_utils.run_gui(gui_config={'AUTO_BACKUP_ENABLED': False, 'HISTORY_ENABLED': True}, libraries={})

Expand Down
1 change: 1 addition & 0 deletions tests/gui/test_resave_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tests import utils as testing_utils


@pytest.mark.timeout(20)
def test_resave(caplog):
testing_utils.initialize_environment(gui_already_started=False)
folder_to_convert = testing_utils.TUTORIAL_PATH
Expand Down
2 changes: 2 additions & 0 deletions tests/gui/test_resave_state_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import rafcon
import subprocess
import sys
import pytest
from tests import utils as testing_utils


@pytest.mark.timeout(20)
def test_library_resave():
script = join(dirname(realpath(rafcon.__file__)), "gui", "resave_state_machines.py")
config_path = join(testing_utils.TESTS_PATH, "assets", "configs", "valid_config")
Expand Down
2 changes: 2 additions & 0 deletions tests/gui/widget/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import threading
import time
import pytest

# core elements
import rafcon.core.singleton
Expand Down Expand Up @@ -1178,6 +1179,7 @@ def test_data_flow_property_modifications_history(caplog):
testing_utils.shutdown_environment(caplog=caplog, unpatch_threading=False)


@pytest.mark.timeout(60)
@pytest.mark.parametrize("with_gui", [False, True])
def test_state_machine_modifications_with_gui(with_gui, caplog):

Expand Down
1 change: 1 addition & 0 deletions tests/gui/widget/test_menu_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def trigger_gui_signals(with_refresh=True, with_substitute_library=True):
assert len(sm_manager_model.state_machines) == 2


@pytest.mark.timeout(30)
def test_gui(caplog):
from os.path import join

Expand Down
1 change: 1 addition & 0 deletions tests/gui/widget/test_restore_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def trigger_gui_signals_second_run(*args):
call_gui_callback(backup_session.reset_session)


@pytest.mark.timeout(20)
def test_restore_session(caplog):
from rafcon.core.storage import storage

Expand Down
1 change: 1 addition & 0 deletions tests/gui/widget/test_states_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def change_state_type(input_and_return_list, new_state_type, state_of_type_chang
# simple type change of root_state -> still could be extended


@pytest.mark.timeout(20)
def test_state_type_change_test(caplog):

testing_utils.run_gui(gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False})
Expand Down

0 comments on commit 727f671

Please sign in to comment.