Skip to content

Commit

Permalink
Configure Travis for pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Mar 14, 2018
1 parent d2a1b7d commit 7a5b667
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install:
- pip install coveralls coverage wheel
- pip install -r requirements.txt
script:
- coverage run --source sismic -m unittest discover
- coverage run --source sismic -m pytest
- coverage run -a --source sismic -m sismic.testing.behave docs/examples/elevator/elevator_contract.yaml --features docs/examples/elevator/elevator.feature --coverage
- coverage run -a --source sismic -m sismic.testing.behave docs/examples/microwave/microwave.yaml --features docs/examples/microwave/heating.feature --coverage --properties docs/examples/microwave/heating_off_property.yaml docs/examples/microwave/heating_on_property.yaml docs/examples/microwave/heating_property.yaml
- coverage run -a --source sismic -m sismic.testing.behave docs/examples/microwave/microwave.yaml --features docs/examples/microwave/heating_human.feature --steps docs/examples/microwave/heating_steps.py --coverage
Expand Down
36 changes: 18 additions & 18 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
@pytest.fixture(params=[False, True], ids=['no contract', 'contract'])
def elevator(request):
if request.param:
filepath = '../docs/examples/elevator/elevator_contract.yaml'
filepath = 'docs/examples/elevator/elevator_contract.yaml'
else:
filepath = '../docs/examples/elevator/elevator.yaml'
filepath = 'docs/examples/elevator/elevator.yaml'
with open(filepath) as f:
sc = import_from_yaml(f)
return Interpreter(sc)


@pytest.fixture
def remote_elevator(elevator):
with open('../docs/examples/elevator/elevator_buttons.yaml') as f:
with open('docs/examples/elevator/elevator_buttons.yaml') as f:
sc = import_from_yaml(f)
remote = Interpreter(sc)
remote.bind(elevator)
Expand All @@ -27,96 +27,96 @@ def remote_elevator(elevator):

@pytest.fixture
def writer():
with open('../docs/examples/writer_options.yaml') as f:
with open('docs/examples/writer_options.yaml') as f:
sc = import_from_yaml(f)
return Interpreter(sc)


@pytest.fixture(params=[False, True], ids=['no contract', 'contract'])
def microwave(request):
if request.param:
filepath = '../docs/examples/microwave/microwave_with_contracts.yaml'
filepath = 'docs/examples/microwave/microwave_with_contracts.yaml'
else:
filepath = '../docs/examples/microwave/microwave.yaml'
filepath = 'docs/examples/microwave/microwave.yaml'
with open(filepath) as f:
sc = import_from_yaml(f)
return Interpreter(sc)


@pytest.fixture
def simple_statechart():
with open('yaml/simple.yaml') as f:
with open('tests/yaml/simple.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def composite_statechart():
with open('yaml/composite.yaml') as f:
with open('tests/yaml/composite.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def deep_history_statechart():
with open('yaml/deep_history.yaml') as f:
with open('tests/yaml/deep_history.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def infinite_statechart():
with open('yaml/infinite.yaml') as f:
with open('tests/yaml/infinite.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def parallel_statechart():
with open('yaml/parallel.yaml') as f:
with open('tests/yaml/parallel.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def nested_parallel_statechart():
with open('yaml/nested_parallel.yaml') as f:
with open('tests/yaml/nested_parallel.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def nondeterministic_statechart():
with open('yaml/nondeterministic.yaml') as f:
with open('tests/yaml/nondeterministic.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def history_statechart():
with open('yaml/history.yaml') as f:
with open('tests/yaml/history.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def composite_statechart():
with open('yaml/composite.yaml') as f:
with open('tests/yaml/composite.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture
def internal_statechart():
with open('yaml/internal.yaml') as f:
with open('tests/yaml/internal.yaml') as f:
statechart = import_from_yaml(f)
return statechart


@pytest.fixture(params=['actions', 'composite', 'deep_history', 'infinite', 'internal',
'nested_parallel', 'nondeterministic', 'parallel', 'simple', 'timer'])
def example_from_tests(request):
with open(os.path.join('yaml', request.param + '.yaml')) as f:
with open(os.path.join('tests', 'yaml', request.param + '.yaml')) as f:
statechart = import_from_yaml(f)
return statechart

Expand All @@ -125,6 +125,6 @@ def example_from_tests(request):
'elevator/tester_elevator_7th_floor_never_reached', 'elevator/tester_elevator_moves_after_10s',
'writer_options'])
def example_from_docs(request):
with open(os.path.join('..', 'docs', 'examples', request.param + '.yaml')) as f:
with open(os.path.join('docs', 'examples', request.param + '.yaml')) as f:
statechart = import_from_yaml(f)
return statechart
2 changes: 1 addition & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from sismic.interpreter import Interpreter, Event
from sismic.interpreter import Event


def test_writer(writer):
Expand Down
1 change: 0 additions & 1 deletion tests/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections import Counter

from sismic.exceptions import ExecutionError, NonDeterminismError, ConflictingTransitionsError
from sismic.io import import_from_yaml
from sismic.code import DummyEvaluator
from sismic.interpreter import Interpreter, Event, InternalEvent
from sismic.helpers import coverage_from_trace, log_trace, run_in_background
Expand Down
2 changes: 1 addition & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_ancestors(self, composite_statechart):

def test_descendants(self, composite_statechart):
assert composite_statechart.descendants_for('s2') == []
assert set(composite_statechart.descendants_for('s1')) == set(['s1a', 's1b', 's1b1', 's1b2'])
assert set(composite_statechart.descendants_for('s1')) == {'s1a', 's1b', 's1b1', 's1b2'}

def test_depth(self, composite_statechart):
assert composite_statechart.depth_for('root') == 1
Expand Down

0 comments on commit 7a5b667

Please sign in to comment.