File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import importlib
2
+ import os
3
+
4
+ import pytest
5
+ from mesa import Model
6
+
7
+
8
+ def get_models (directory ):
9
+ models = []
10
+ for root , dirs , files in os .walk (directory ):
11
+ for file in files :
12
+ if file == "model.py" :
13
+ module_name = os .path .relpath (os .path .join (root , file [:- 3 ])).replace (
14
+ os .sep , "."
15
+ )
16
+
17
+ module = importlib .import_module (module_name )
18
+ for item in dir (module ):
19
+ obj = getattr (module , item )
20
+ if (
21
+ isinstance (obj , type )
22
+ and issubclass (obj , Model )
23
+ and obj is not Model
24
+ ):
25
+ models .append (obj )
26
+
27
+ return models
28
+
29
+
30
+ @pytest .mark .parametrize ("model_class" , get_models ("gis" ))
31
+ def test_model_steps (model_class ):
32
+ model = model_class () # Assume no arguments are needed
33
+ for _ in range (10 ):
34
+ model .step ()
You can’t perform that action at this time.
0 commit comments