Skip to content

Commit

Permalink
Add pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
glatteis committed Jun 25, 2024
1 parent a27f34b commit 4eb4bdd
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
70 changes: 69 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.12"

[tool.poetry.group.test.dependencies]
pytest = "^8.2.2"

[tool.poetry.group.lint.dependencies]
pre-commit = "^3.7.1"
ruff = "^0.4.6"
Expand Down
Empty file added tests/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions tests/test_model_creation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# content of test_sysexit.py
import stormvogel.model


def test_mdp_creation():
dtmc = stormvogel.model.new_dtmc("Die")

init = dtmc.get_initial_state()

# roll die
init.set_transitions(
[(1 / 6, dtmc.new_state(f"rolled{i}", {"rolled": i})) for i in range(6)]
)

assert len(dtmc.states) == 7
assert len(dtmc.transitions) == 7
# Check that all states 1..6 have self loops
for i in range(1, 7):
# yeah we need transition getting syntax
assert (
dtmc.transitions[i].transition[stormvogel.model.EmptyAction].branch[0][1].id
== i
)

0 comments on commit 4eb4bdd

Please sign in to comment.