forked from projectmesa/mesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_model.py
39 lines (29 loc) · 869 Bytes
/
test_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from mesa.model import Model
def test_model_set_up():
model = Model()
assert model.running is True
assert model.schedule is None
assert model.current_id == 0
assert model.current_id + 1 == model.next_id()
assert model.current_id == 1
model.step()
def test_running():
class TestModel(Model):
steps = 0
def step(self):
"""Increase steps until 10."""
self.steps += 1
if self.steps == 10:
self.running = False
model = TestModel()
model.run_model()
def test_seed(seed=23):
model = Model(seed=seed)
assert model._seed == seed
def test_reset_randomizer(newseed=42):
model = Model()
oldseed = model._seed
model.reset_randomizer()
assert model._seed == oldseed
model.reset_randomizer(seed=newseed)
assert model._seed == newseed