Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Dec 25, 2015
1 parent 14c93b2 commit e73cc66
Showing 1 changed file with 21 additions and 34 deletions.
55 changes: 21 additions & 34 deletions tests/test_io.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,35 @@
import os
import unittest
from sismic import io


class ImportFromYamlTests(unittest.TestCase):
def test_yaml_tests(self):
io.import_from_yaml(open('tests/yaml/actions.yaml'))
io.import_from_yaml(open('tests/yaml/composite.yaml'))
io.import_from_yaml(open('tests/yaml/deep_history.yaml'))
io.import_from_yaml(open('tests/yaml/history.yaml'))
io.import_from_yaml(open('tests/yaml/infinite.yaml'))
io.import_from_yaml(open('tests/yaml/internal.yaml'))
io.import_from_yaml(open('tests/yaml/nested_parallel.yaml'))
io.import_from_yaml(open('tests/yaml/nondeterministic.yaml'))
io.import_from_yaml(open('tests/yaml/parallel.yaml'))
io.import_from_yaml(open('tests/yaml/simple.yaml'))
io.import_from_yaml(open('tests/yaml/timer.yaml'))
files = ['actions', 'composite', 'deep_history', 'infinite', 'internal', 'nested_parallel',
'nondeterministic', 'parallel', 'simple', 'timer']
for f in files:
io.import_from_yaml(open(os.path.join('tests', 'yaml', f+'.yaml')))

def test_examples(self):
io.import_from_yaml(open('examples/elevator.yaml'))
io.import_from_yaml(open('examples/elevator_contract.yaml'))
io.import_from_yaml(open('examples/microwave.yaml'))
io.import_from_yaml(open('examples/tester_elevator_7th_floor_never_reached.yaml'))
io.import_from_yaml(open('examples/tester_elevator_moves_after_10s.yaml'))
io.import_from_yaml(open('examples/writer_options.yaml'))
files = ['elevator', 'elevator_contract', 'microwave', 'tester_elevator_7th_floor_never_reached',
'tester_elevator_moves_after_10s', 'writer_options']
for f in files:
io.import_from_yaml(open(os.path.join('examples', f+'.yaml')))


class ExportToDictYAMLTests(unittest.TestCase):
def test_yaml_tests(self):
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/actions.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/composite.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/deep_history.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/history.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/infinite.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/internal.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/nested_parallel.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/nondeterministic.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/parallel.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/simple.yaml')))
io.export_to_yaml(io.import_from_yaml(open('tests/yaml/timer.yaml')))
files = ['actions', 'composite', 'deep_history', 'infinite', 'internal', 'nested_parallel',
'nondeterministic', 'parallel', 'simple', 'timer']
for f in files:
d = io.export_to_yaml(io.import_from_yaml(open(os.path.join('tests', 'yaml', f+'.yaml'))))
# check
io.import_from_yaml(d)

def test_examples(self):
io.export_to_yaml(io.import_from_yaml(open('examples/elevator.yaml')))
io.export_to_yaml(io.import_from_yaml(open('examples/elevator_contract.yaml')))
io.export_to_yaml(io.import_from_yaml(open('examples/microwave.yaml')))
io.export_to_yaml(io.import_from_yaml(open('examples/tester_elevator_7th_floor_never_reached.yaml')))
io.export_to_yaml(io.import_from_yaml(open('examples/tester_elevator_moves_after_10s.yaml')))
io.export_to_yaml(io.import_from_yaml(open('examples/writer_options.yaml')))
files = ['elevator', 'elevator_contract', 'microwave', 'tester_elevator_7th_floor_never_reached',
'tester_elevator_moves_after_10s', 'writer_options']
for f in files:
d = io.export_to_yaml(io.import_from_yaml(open(os.path.join('examples', f+'.yaml'))))
# check
io.import_from_yaml(d)

0 comments on commit e73cc66

Please sign in to comment.