Browse Source

make sure that examples are run when running tests

refactoring
Sebastian Junges 7 years ago
parent
commit
aed4dffd13
  1. 2
      examples/01-getting-started.py
  2. 2
      examples/02-getting-started.py
  3. 4
      examples/03-getting-started.py
  4. 6
      examples/04-getting-started.py
  5. 8
      setup.cfg
  6. 1
      setup.py

2
examples/01-getting-started.py

@ -13,5 +13,5 @@ def example_getting_started_01():
print("Number of transitions: {}".format(model.nr_transitions)) print("Number of transitions: {}".format(model.nr_transitions))
print("Labels: {}".format(model.labeling.get_labels())) print("Labels: {}".format(model.labeling.get_labels()))
if __name__ == 'main':
if __name__ == '__main__':
example_getting_started_01() example_getting_started_01()

2
examples/02-getting-started.py

@ -29,5 +29,5 @@ def example_getting_started_02():
print("Number of transitions: {}".format(model_for_formula_2.nr_transitions)) print("Number of transitions: {}".format(model_for_formula_2.nr_transitions))
print("Labels in the model: {}".format(model_for_formula_2.labeling.get_labels())) print("Labels in the model: {}".format(model_for_formula_2.labeling.get_labels()))
if __name__ == 'main':
if __name__ == '__main__':
example_getting_started_02() example_getting_started_02()

4
examples/03-getting-started.py

@ -17,6 +17,8 @@ def example_getting_started_03():
assert result.result_for_all_states assert result.result_for_all_states
for x in result.get_values(): for x in result.get_values():
print(x) print(x)
initial_state = model.initial_states[0]
print(result.at(initial_state))
if __name__ == 'main':
if __name__ == '__main__':
example_getting_started_03() example_getting_started_03()

6
examples/04-getting-started.py

@ -17,15 +17,17 @@ def example_getting_started_04():
properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program) properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program)
model = stormpy.build_parametric_model(prism_program, properties) model = stormpy.build_parametric_model(prism_program, properties)
print("Model supports parameters: {}".format(model.supports_parameters)) print("Model supports parameters: {}".format(model.supports_parameters))
parameters = model.collect_probability_parameters()
assert len(parameters) == 2
instantiator = stormpy.pars.PDtmcInstantiator(model) instantiator = stormpy.pars.PDtmcInstantiator(model)
point = dict() point = dict()
parameters = model.collect_probability_parameters()
for x in parameters: for x in parameters:
print(x.name) print(x.name)
point[x] = stormpy.RationalRF(0.4) point[x] = stormpy.RationalRF(0.4)
instantiated_model = instantiator.instantiate(point) instantiated_model = instantiator.instantiate(point)
result = stormpy.model_checking(instantiated_model, properties[0]) result = stormpy.model_checking(instantiated_model, properties[0])
print(result)
if __name__ == 'main':
if __name__ == '__main__':
example_getting_started_04() example_getting_started_04()

8
setup.cfg

@ -0,0 +1,8 @@
[aliases]
test=pytest
[tool:pytest]
addopts = --doctest-glob='*.rst'
testpaths = tests/ examples/
python_files = test*.py examples/*.py
python_functions = *_test test_* example_*

1
setup.py

@ -196,5 +196,6 @@ setup(
cmdclass={'build_ext': CMakeBuild, 'test': PyTest}, cmdclass={'build_ext': CMakeBuild, 'test': PyTest},
zip_safe=False, zip_safe=False,
install_requires=['pycarl>=2.0.0'], install_requires=['pycarl>=2.0.0'],
setup_requires=['pytest-runner'],
tests_require=['pytest'], tests_require=['pytest'],
) )
Loading…
Cancel
Save