mitogen/tests/jail_test.py

34 lines
769 B
Python
Raw Normal View History

2019-03-10 20:01:54 +00:00
import os
import mitogen
import mitogen.parent
import unittest2
import testlib
class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
jexec_path = testlib.data_path('stubs/stub-jexec.py')
def test_okay(self):
context = self.router.jail(
jexec_path=self.jexec_path,
container='somejail',
)
2019-03-10 23:01:52 +00:00
stream = self.router.stream_by_id(context.context_id)
2019-03-10 20:01:54 +00:00
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[:4], [
self.jexec_path,
2019-03-10 23:01:52 +00:00
'somejail',
stream.conn.options.python_path,
'-c',
2019-03-10 20:01:54 +00:00
])
2019-03-10 23:01:52 +00:00
self.assertEquals('1', context.call(os.getenv, 'THIS_IS_STUB_JEXEC'))
2019-03-10 20:01:54 +00:00
if __name__ == '__main__':
unittest2.main()