Browse Source

Skip tests if submodules are not supported

refactoring
Matthias Volk 7 years ago
parent
commit
14eedd6ca3
  1. 2
      lib/stormpy/dft/__init__.py
  2. 2
      lib/stormpy/pars/__init__.py
  3. 7
      setup.py
  4. 10
      tests/configurations.py
  5. 4
      tests/dft/conftest.py
  6. 11
      tests/dft/test_build.py
  7. 4
      tests/pars/conftest.py
  8. 4
      tests/pars/test_model_instantiator.py
  9. 5
      tests/pars/test_parametric.py
  10. 5
      tests/pars/test_pla.py

2
lib/stormpy/dft/__init__.py

@ -1,6 +1,6 @@
from . import _config from . import _config
if not _config.has_storm_dft:
if not _config.storm_with_dft:
raise ImportError("No support for DFTs was built in Storm.") raise ImportError("No support for DFTs was built in Storm.")
from . import dft from . import dft

2
lib/stormpy/pars/__init__.py

@ -1,6 +1,6 @@
from . import _config from . import _config
if not _config.has_storm_pars:
if not _config.storm_with_pars:
raise ImportError("No support for parametric analysis was built in Storm.") raise ImportError("No support for parametric analysis was built in Storm.")
from . import pars from . import pars

7
setup.py

@ -127,6 +127,9 @@ class CMakeBuild(build_ext):
f.write("FactorizedPolynomial = pycarl.{}.FactorizedPolynomial\n".format(rfpackage)) f.write("FactorizedPolynomial = pycarl.{}.FactorizedPolynomial\n".format(rfpackage))
f.write("RationalFunction = pycarl.{}.RationalFunction\n".format(rfpackage)) f.write("RationalFunction = pycarl.{}.RationalFunction\n".format(rfpackage))
f.write("FactorizedRationalFunction = pycarl.{}.FactorizedRationalFunction\n".format(rfpackage)) f.write("FactorizedRationalFunction = pycarl.{}.FactorizedRationalFunction\n".format(rfpackage))
f.write("\n")
f.write("storm_with_pars = {}\n".format(self.conf.HAVE_STORM_PARS))
f.write("storm_with_dft = {}\n".format(self.conf.HAVE_STORM_DFT))
elif ext.name == "info": elif ext.name == "info":
with open(os.path.join(self.extdir(ext.name), ext.subdir, "_config.py"), "w") as f: with open(os.path.join(self.extdir(ext.name), ext.subdir, "_config.py"), "w") as f:
@ -137,14 +140,14 @@ class CMakeBuild(build_ext):
elif ext.name == "pars": elif ext.name == "pars":
with open(os.path.join(self.extdir(ext.name), ext.subdir, "_config.py"), "w") as f: with open(os.path.join(self.extdir(ext.name), ext.subdir, "_config.py"), "w") as f:
f.write("# Generated from setup.py at {}\n".format(datetime.datetime.now())) f.write("# Generated from setup.py at {}\n".format(datetime.datetime.now()))
f.write("has_storm_pars = {}".format(self.conf.HAVE_STORM_PARS))
f.write("storm_with_pars = {}".format(self.conf.HAVE_STORM_PARS))
if not self.conf.HAVE_STORM_PARS: if not self.conf.HAVE_STORM_PARS:
print("WARNING: storm-pars not found. No support for parametric analysis will be built.") print("WARNING: storm-pars not found. No support for parametric analysis will be built.")
continue continue
elif ext.name == "dft": elif ext.name == "dft":
with open(os.path.join(self.extdir(ext.name), ext.subdir, "_config.py"), "w") as f: with open(os.path.join(self.extdir(ext.name), ext.subdir, "_config.py"), "w") as f:
f.write("# Generated from setup.py at {}\n".format(datetime.datetime.now())) f.write("# Generated from setup.py at {}\n".format(datetime.datetime.now()))
f.write("has_storm_dft = {}".format(self.conf.HAVE_STORM_DFT))
f.write("storm_with_dft = {}".format(self.conf.HAVE_STORM_DFT))
if not self.conf.HAVE_STORM_DFT: if not self.conf.HAVE_STORM_DFT:
print("WARNING: storm-dft not found. No support for DFTs will be built.") print("WARNING: storm-dft not found. No support for DFTs will be built.")
continue continue

10
tests/configurations.py

@ -0,0 +1,10 @@
import pytest
import stormpy._config as config
# Skip not supported functionality
has_dft = config.storm_with_dft
has_pars = config.storm_with_pars
dft = pytest.mark.skipif(not has_dft, reason="No support for DFTs")
pars = pytest.mark.skipif(not has_pars, reason="No support for parametric model checking")

4
tests/dft/conftest.py

@ -0,0 +1,4 @@
from configurations import has_dft
if has_dft:
import stormpy.dft

11
tests/dft/test_build.py

@ -3,19 +3,12 @@ import stormpy.logic
from helpers.helper import get_example_path from helpers.helper import get_example_path
import math import math
from configurations import dft
@dft
class TestBuild: class TestBuild:
def test_import(self):
import stormpy.dft
def test_build_dft(self): def test_build_dft(self):
try:
import stormpy.dft
except ImportError:
# No support for DFTs
return
model = stormpy.dft.build_sparse_model_from_json_dft(get_example_path("dft", "and.json")) model = stormpy.dft.build_sparse_model_from_json_dft(get_example_path("dft", "and.json"))
formulas = stormpy.parse_properties("T=? [ F \"failed\" ]") formulas = stormpy.parse_properties("T=? [ F \"failed\" ]")
assert model.nr_states == 4 assert model.nr_states == 4

4
tests/pars/conftest.py

@ -0,0 +1,4 @@
from configurations import has_pars
if has_pars:
import stormpy.pars

4
tests/pars/test_model_instantiator.py

@ -1,9 +1,11 @@
import stormpy import stormpy
import stormpy.logic import stormpy.logic
import stormpy.pars
from helpers.helper import get_example_path from helpers.helper import get_example_path
from configurations import pars
@pars
class TestModelInstantiator: class TestModelInstantiator:
def test_instantiate_dtmc(self): def test_instantiate_dtmc(self):
program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm")) program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))

5
tests/pars/test_parametric.py

@ -3,8 +3,13 @@ import stormpy.info
import stormpy.logic import stormpy.logic
from helpers.helper import get_example_path from helpers.helper import get_example_path
from configurations import pars
@pars
class TestParametric: class TestParametric:
import stormpy.pars
def test_constraints_collector(self): def test_constraints_collector(self):
from pycarl.formula import FormulaType, Relation from pycarl.formula import FormulaType, Relation
if stormpy.info.storm_ratfunc_use_cln(): if stormpy.info.storm_ratfunc_use_cln():

5
tests/pars/test_pla.py

@ -1,11 +1,14 @@
import stormpy import stormpy
import stormpy.logic import stormpy.logic
import stormpy.pars
from helpers.helper import get_example_path from helpers.helper import get_example_path
from configurations import pars
@pars
class TestPLA: class TestPLA:
def test_pla(self): def test_pla(self):
import stormpy.pars
program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm")) program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
prop = "P<=0.84 [F s=5 ]" prop = "P<=0.84 [F s=5 ]"
formulas = stormpy.parse_properties_for_prism_program(prop, program) formulas = stormpy.parse_properties_for_prism_program(prop, program)

Loading…
Cancel
Save