Skip to content

Commit ef37443

Browse files
committed
add test to simulate remote module execution
1 parent fd63b36 commit ef37443

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

testing/test_gateway.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,37 @@ def test_remote_exec_module(self, tmpdir, gw):
122122
name = channel.receive()
123123
assert name == 2
124124

125+
def test_remote_exec_module_is_removed(self, gw, tmpdir, monkeypatch):
126+
remotetest = tmpdir.join("remote.py")
127+
remotetest.write(
128+
dedent(
129+
"""
130+
def remote():
131+
return True
132+
133+
if __name__ == '__channelexec__':
134+
for item in channel: # noqa
135+
channel.send(eval(item)) # noqa
136+
137+
"""
138+
)
139+
)
140+
141+
monkeypatch.syspath_prepend(tmpdir)
142+
import remote
143+
144+
ch = gw.remote_exec(remote)
145+
# simulate sending the code to a remote location that does not have
146+
# access to the source
147+
tmpdir.remove()
148+
ch.send("remote()")
149+
try:
150+
result = ch.receive()
151+
finally:
152+
ch.close()
153+
154+
assert result is True
155+
125156
def test_remote_exec_module_with_traceback(self, gw, tmpdir, monkeypatch):
126157
remotetest = tmpdir.join("remotetest.py")
127158
remotetest.write(

0 commit comments

Comments
 (0)