Skip to content

Commit

Permalink
Create script to test GIS examples
Browse files Browse the repository at this point in the history
Co-Authored-By: rht <[email protected]>
  • Loading branch information
EwoutH and rht committed Aug 25, 2024
1 parent 8408368 commit 377bf15
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test_gis_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import importlib
import os

import pytest
from mesa import Model


def get_models(directory):
models = []
for root, dirs, files in os.walk(directory):
for file in files:
if file == "model.py":
module_name = os.path.relpath(os.path.join(root, file[:-3])).replace(
os.sep, "."
)

module = importlib.import_module(module_name)
for item in dir(module):
obj = getattr(module, item)
if (
isinstance(obj, type)
and issubclass(obj, Model)
and obj is not Model
):
models.append(obj)

return models


@pytest.mark.parametrize("model_class", get_models("gis"))
def test_model_steps(model_class):
model = model_class() # Assume no arguments are needed
for _ in range(10):
model.step()

0 comments on commit 377bf15

Please sign in to comment.