Commits

luensdorf  committed 8007eb7

Fixed resume behavior of ``simulate()`` and added a test.

  • Participants
  • Parent commits a0f5f10

Comments (0)

Files changed (2)

File simpy/core.py

     if until is None:
         until = env.event()
     elif not hasattr(until, 'callbacks'):
-        until = env.timeout(until)
+        until = env.timeout(until - env.now)
 
     events = env._events
     while events and until.callbacks is not None:

File simpy/test/test_single_process.py

         step(env)
     assert proc.target is event
     proc.interrupt()
+
+
+def test_simulate_resume(env):
+    """Stopped simulation can be resumed."""
+    events = [env.timeout(t) for t in (5, 10, 15)]
+
+    simulate(env, until=10)
+    assert events[0].processed and events[1].processed
+    assert env.now == 10
+
+    simulate(env, until=15)
+    assert events[2].processed
+    assert env.now == 15