/usr/lib/python2.7/dist-packages/SimPy/test/test_simident.py is in python-simpy 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | # coding=utf-8
"""
Unit tests of checks of correct use of sim parameter.
2.1 introduces checks that two entities involved in a yield (e.g.
a Process and a Resource) belong to the same Simulation instance.
"""
from SimPy.Simulation import *
class Activatetest(Process):
"""Used in testActivate.
"""
def run(self):
yield hold,self,0
class Requesttest(Process):
"""Used in testRequest.
"""
def run(self,res):
yield request,self,res
class PutStoretest(Process):
"""Used in testPutStore.
"""
def run(self,store):
yield put,self,store,[1]
class GetStoretest(Process):
"""Used in testGetStore.
"""
def run(self,store):
yield get,self,store,1
class PutLeveltest(Process):
"""Used in testPutLevel.
"""
def run(self,level):
yield put,self,level,1
class GetLeveltest(Process):
"""Used in testGetLevel.
"""
def run(self,level):
yield get,self,level,1
class Waiteventtest(Process):
"""Used in testWaitevent.
"""
def run(self,event):
yield waitevent,self,event
class Queueeventtest(Process):
"""Used in testQueueevent.
"""
def run(self,event):
yield queueevent,self,event
def test_activate():
"""Test of "activate" call"""
s = Simulation()
s.initialize()
r = Activatetest(sim=s)
try:
activate(r,r.run()) ## missing s.
except FatalSimerror:
pass
else:
assert False, "expected FatalSimerror"
s.simulate(until=1)
def test_request():
"""Test of "yield request,self,res" """
s = Simulation()
s.initialize()
res = Resource( ) # wrong sim
r = Requesttest(sim=s)
s.activate(r,r.run(res = res))
try:
s.simulate(until=1)
except FatalSimerror:
pass
else:
assert False, "expected FatalSimerror"
def test_put_store():
"""Test of "yield put,self,store" """
s = Simulation()
s.initialize()
store = Store( ) # wrong sim
r = PutStoretest(sim=s)
s.activate(r,r.run(store = store))
try:
s.simulate(until=1)
except FatalSimerror:
pass
else:
assert False, "expected FatalSimerror"
def test_put_level():
"""Test of "yield put,self,level" """
s = Simulation()
s.initialize()
levl = Level( ) # wrong sim
r = PutLeveltest(sim=s)
s.activate(r,r.run(level = levl))
try:
s.simulate(until=1)
except FatalSimerror:
pass
else:
assert False, "expected FatalSimerror"
def test_get_store():
"""Test of "yield get,self,store" """
s = Simulation()
s.initialize()
store = Store( ) # wrong sim
r = GetStoretest(sim=s)
s.activate(r,r.run(store = store))
try:
s.simulate(until=1)
except FatalSimerror:
pass
else:
assert False, "expected FatalSimerror"
def test_get_level():
"""Test of "yield get,self,level" """
s = Simulation()
s.initialize()
levl = Level( ) # wrong sim
r = GetLeveltest(sim=s)
s.activate(r,r.run(level = levl))
try:
s.simulate(until=1)
except FatalSimerror:
pass
else:
assert False, "expected FatalSimerror"
def test_waitevent():
"""Test of "yield waitevent,self,evt" """
s = Simulation()
s.initialize()
evt = SimEvent() ## wrong sim
w = Waiteventtest(sim = s)
s.activate(w,w.run(event = evt))
try:
s.simulate(until=1)
except FatalSimerror:
pass
else:
assert False, "expected FatalSimerror"
def test_queueevent():
"""Test of "yield queueevent,self,evt" """
s = Simulation()
s.initialize()
evt = SimEvent() ## wrong sim
w = Queueeventtest(sim = s)
s.activate(w,w.run(event = evt))
try:
s.simulate(until=1)
except FatalSimerror:
pass
else:
assert False, "expected FatalSimerror"
|