2022-07-05 10:08:34 +00:00
|
|
|
from unittest import TestCase
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from soil import agents, environment
|
|
|
|
from soil import time as stime
|
|
|
|
|
2022-10-16 15:54:03 +00:00
|
|
|
|
2022-07-05 10:08:34 +00:00
|
|
|
class Dead(agents.FSM):
|
|
|
|
@agents.default_state
|
|
|
|
@agents.state
|
|
|
|
def only(self):
|
2022-10-13 20:43:16 +00:00
|
|
|
return self.die()
|
2022-07-05 10:08:34 +00:00
|
|
|
|
2022-10-16 15:54:03 +00:00
|
|
|
|
2022-07-05 10:08:34 +00:00
|
|
|
class TestMain(TestCase):
|
|
|
|
def test_die_raises_exception(self):
|
|
|
|
d = Dead(unique_id=0, model=environment.Environment())
|
|
|
|
d.step()
|
|
|
|
with pytest.raises(agents.DeadAgent):
|
|
|
|
d.step()
|
2022-07-06 07:23:18 +00:00
|
|
|
|
2022-07-05 10:08:34 +00:00
|
|
|
def test_die_returns_infinity(self):
|
|
|
|
d = Dead(unique_id=0, model=environment.Environment())
|
2022-10-13 20:43:16 +00:00
|
|
|
ret = d.step().abs(0)
|
2022-10-16 15:54:03 +00:00
|
|
|
print(ret, "next")
|
2022-10-13 20:43:16 +00:00
|
|
|
assert ret == stime.INFINITY
|