Skip to content

Commit

Permalink
Merge pull request #692 from common/feature/tox
Browse files Browse the repository at this point in the history
Add tox integration
  • Loading branch information
sebastian-brunner authored and GitHub Enterprise committed Mar 7, 2019
2 parents 3a6c4d3 + 6e0bf20 commit f1deeb6
Show file tree
Hide file tree
Showing 103 changed files with 312 additions and 219 deletions.
12 changes: 12 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ Next Release


- Improvements:

- add tox integration

- run tests under Python interpreters 2.7, 3.4, 3.5, 3.6, 3.7
- run tests with coverage
- build documentation and check links
- check sdist

- optimize setup_requires in setup.py (faster installation)
- mark unreliable tests as unstable
- define timeouts for all tests


- Bug Fixes:
Expand Down Expand Up @@ -43,6 +54,7 @@ Next Release
- :issue_ghe:`684` ``test_simple_execution_model_and_core_destruct_with_gui`` fails when running core & gui tests in a row
- fix pause and step mode behavior
- installation of fonts under Python 3
- various test fixed for Python 3


0.13.5
Expand Down
8 changes: 7 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[pytest]
# Use catchlog instead of capturelog
addopts = -p no:pytest_capturelog
addopts = -x -p no:pytest_capturelog
testpaths = tests
norecursedirs = .git all source share doc
timeout = 10
timeout_method = thread
markers =
unstable: mark a test as not running reliable all the time
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[aliases]
test=pytest

[build_sphinx]
source-dir = doc/
build-dir = build_doc/
Expand Down
46 changes: 8 additions & 38 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@

from __future__ import print_function
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
from setuptools.command.develop import develop as DevelopCommand
from setuptools.command.install import install as InstallCommand
from os import path
import os
import sys
from imp import load_source
import distutils.log as log


rafcon_root_path = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -31,38 +28,6 @@
installation = load_source("installation", install_helper)


class PyTest(TestCommand):
"""Run py.test with RAFCON tests
Copied http://doc.pytest.org/en/latest/goodpractices.html#integrating-with-setuptools-python-setup-py-test-pytest-runner
"""
# This allows the user to add custom parameters to py.test, e.g.
# $ python setup.py test -a "-v"
user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]

def initialize_options(self):
TestCommand.initialize_options(self)
# Add further test folder with 'or my_test_folder'
# self.pytest_args = '-vx -s -k "core or gui or share_elements or user_input"'
# self.pytest_args = '-vx -s -k "core or gui or share_elements"'
# self.pytest_args = '-vx -s -k "user_input"'
self.pytest_args = '-vx -s -k "not tests_in_processes and not assests and not network ' \
'and not performance and not user_input"'

def run_tests(self):
import shlex
import pytest # import here, cause outside the eggs aren't loaded
test_path = path.join(path.dirname(path.abspath(__file__)), 'tests')
rafcon_path = path.join(path.dirname(path.abspath(__file__)), 'source')
sys.path.insert(0, test_path)
sys.path.insert(0, rafcon_path)
os.environ["PYTHONPATH"] = rafcon_path + os.pathsep + test_path + os.pathsep + os.environ["PYTHONPATH"]
log.info("\nRunning pytest with the following arguments: {}\n".format(shlex.split(self.pytest_args) + [
'tests']))
error_number = pytest.main(shlex.split(self.pytest_args) + ['tests'])
sys.exit(error_number)


class PostDevelopCommand(DevelopCommand):
"""Post installation step for development mode
"""
Expand Down Expand Up @@ -96,6 +61,8 @@ 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-timeout', 'pytest-catchlog', 'graphviz', 'pyuserinput'] + global_requirements

setup(
name='rafcon',
version=version,
Expand All @@ -122,10 +89,14 @@ def run(self):

data_files=installation.generate_data_files(),

setup_requires=['Sphinx>=1.4', 'libsass >= 0.15.0'] + global_requirements,
tests_require=['pytest', 'pytest-catchlog', 'graphviz', 'pyuserinput'] + global_requirements,
setup_requires=['pytest-runner', 'libsass >= 0.15.0'],
tests_require=test_requirements,
install_requires=global_requirements,

extras_require={
'testing': test_requirements
},

sass_manifests={
'rafcon': {
'sass_path': 'gui/assets/share/themes/RAFCON/sass',
Expand All @@ -147,7 +118,6 @@ def run(self):
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
'test': PyTest
},

keywords=('state machine', 'robotic', 'FSM', 'development', 'GUI', 'visual programming'),
Expand Down
4 changes: 3 additions & 1 deletion source/rafcon/utils/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ def create_mo_files():
import subprocess
data_files = []
domain = "rafcon"
assert "setup.py" in os.listdir(os.curdir)
rel_localedir = path.join('source', 'rafcon', 'locale')
localedir = os.path.join(rafcon_root_path, rel_localedir)
localedir = os.path.join(os.curdir, rel_localedir)
# Assert that we are in the root directory of the RAFCON repository
po_files = [po_file
for po_file in next(os.walk(localedir))[2]
if path.splitext(po_file)[1] == '.po']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from testing_utils import RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE
from tests.utils import RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE
FILE_TO_MODIFY = RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE + "/test_start_script.txt"


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from testing_utils import RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE
from tests.utils import RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE
FILE_TO_MODIFY = RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE + "/test_start_script.txt"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
"__jsonqualname__": "rafcon.core.states.hierarchy_state.HierarchyState",
"data_flows": {},
"description": null,
"income": {
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Income"
},
"input_data_ports": {},
"name": "start_script_test",
"outcomes": {
"-2": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "preempted",
"outcome_id": -2
},
"-1": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "aborted",
"outcome_id": -1
},
"0": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "success",
"outcome_id": 0
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
{
"__jsonqualname__": "rafcon.core.states.execution_state.ExecutionState",
"description": null,
"income": {
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Income"
},
"input_data_ports": {},
"name": "state_1",
"outcomes": {
"-2": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "preempted",
"outcome_id": -2
},
"-1": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "aborted",
"outcome_id": -1
},
"0": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "success",
"outcome_id": 0
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from testing_utils import RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE
from os.path import join
from rafcon.utils import constants
RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE = join(constants.RAFCON_TEMP_PATH_BASE, '..', 'unit_tests')
FILE_TO_MODIFY = RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE + "/test_start_script.txt"


Expand All @@ -8,4 +10,4 @@ def execute(self, inputs, outputs, gvm):
with open(FILE_TO_MODIFY, "w+") as f:
f.write("start, ")

return 0
return 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
{
"__jsonqualname__": "rafcon.core.states.execution_state.ExecutionState",
"description": null,
"income": {
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Income"
},
"input_data_ports": {},
"name": "state_2",
"outcomes": {
"-2": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "preempted",
"outcome_id": -2
},
"-1": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "aborted",
"outcome_id": -1
},
"0": {
"__jsonqualname__": "rafcon.core.state_elements.outcome.Outcome",
"__jsonqualname__": "rafcon.core.state_elements.logical_port.Outcome",
"name": "success",
"outcome_id": 0
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from testing_utils import RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE
from os.path import join
from rafcon.utils import constants
RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE = join(constants.RAFCON_TEMP_PATH_BASE, '..', 'unit_tests')
FILE_TO_MODIFY = RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE + "/test_start_script.txt"


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"creation_time": "2016-06-02 12:12:02",
"last_update": "2017-01-13 10:53:10",
"last_update": "2019-02-28 12:03:17",
"root_state_storage_id": "start_script_test_UTUOSC",
"state_machine_version": null,
"used_rafcon_version": "0.8.3"
"used_rafcon_version": "0.13.5"
}
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# and thus all variables (incl. singletons) are reinitialized
# def pytest_configure(config):
# if any(x in str(config.invocation_dir) for x in ["gui", "share_elements", "widget", "network"]):
# import testing_utils
# import utils
# testing_utils.run_gui(gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False})
# try:
# # do nothing, just open gui and close it afterwards
Expand Down Expand Up @@ -62,7 +62,7 @@ def restore_configs():
def clean_temp_test_directory():
import shutil
import os
from . import testing_utils
from tests import utils as testing_utils
test_temp_path = testing_utils.RAFCON_TEMP_PATH_TEST_BASE
try:
shutil.rmtree(test_temp_path)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_concurrency_barrier_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# test environment elements
import pytest
import testing_utils
from tests import utils as testing_utils
from rafcon.core.constants import UNIQUE_DECIDER_STATE_ID


Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_custom_entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import rafcon.core.singleton

# test environment elements
import testing_utils
from tests import utils as testing_utils


def test_custom_entry_point(caplog):
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_data_ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import rafcon.core.singleton

# test environment elements
import testing_utils
from tests import utils as testing_utils


def create_state_machine():
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_error_preemption_handling.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from builtins import object
import os
import pytest
import testing_utils
from tests import utils as testing_utils

from rafcon.core.storage import storage as global_storage

Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_error_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# singleton elements
from rafcon.core.singleton import state_machine_manager, state_machine_execution_engine

import testing_utils
from tests import utils as testing_utils

def test_error_propagation(caplog):
testing_utils.initialize_environment_core()
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_execute_script_returns_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import rafcon.core.singleton
from rafcon.core.storage import storage

import testing_utils
from tests import utils as testing_utils


def test_execute_script_returns_none(caplog):
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_execution_history_file_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# test environment elements
import pytest
import testing_utils
from tests import utils as testing_utils
import os


Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_global_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rafcon.core.state_machine import StateMachine

# test environment elements
import testing_utils
from tests import utils as testing_utils


def create_state_machine():
Expand Down Expand Up @@ -47,4 +47,4 @@ def test_concurrency_barrier_state_execution(caplog):


if __name__ == '__main__':
pytest.main([__file__])
pytest.main([__file__])
2 changes: 1 addition & 1 deletion tests/core/test_gvm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rafcon.core.global_variable_manager import GlobalVariableManager
import pytest
import testing_utils
from tests import utils as testing_utils
from pytest import raises


Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_hierarchy_state_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rafcon.core.state_elements.data_port import InputDataPort, OutputDataPort

# test environment elements
import testing_utils
from tests import utils as testing_utils


def create_hierarchy_state():
Expand Down
Loading

0 comments on commit f1deeb6

Please sign in to comment.