From 3206d59c8767853004f087c7426deaff40c666f0 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 7 Nov 2018 00:13:05 +0000 Subject: [PATCH] issue #426: teach DockerMixin to allow selecting interpreter --- tests/testlib.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/testlib.py b/tests/testlib.py index b9a1bec5..19f6ed86 100644 --- a/tests/testlib.py +++ b/tests/testlib.py @@ -331,13 +331,17 @@ def get_docker_host(): class DockerizedSshDaemon(object): - image = None + distro, _, _py3 = ( + os.environ.get('MITOGEN_TEST_DISTRO', 'debian') + .partition('-') + ) - def get_image(self): - if not self.image: - distro = os.environ.get('MITOGEN_TEST_DISTRO', 'debian') - self.image = 'mitogen/%s-test' % (distro,) - return self.image + python_path = ( + '/usr/bin/python3' + if _py3 == 'py3' + else '/usr/bin/python' + ) + image = 'mitogen/%s-test' % (distro,) # 22/tcp -> 0.0.0.0:32771 PORT_RE = re.compile(r'([^/]+)/([^ ]+) -> ([^:]+):(.*)') @@ -363,7 +367,7 @@ class DockerizedSshDaemon(object): '--privileged', '--publish-all', '--name', self.container_name, - self.get_image() + self.image, ] subprocess__check_output(args) self._get_container_port() @@ -423,6 +427,7 @@ class DockerMixin(RouterMixin): kwargs.setdefault('port', self.dockerized_ssh.port) kwargs.setdefault('check_host_keys', 'ignore') kwargs.setdefault('ssh_debug_level', 3) + kwargs.setdefault('python_path', self.dockerized_ssh.python_path) return self.router.ssh(**kwargs) def docker_ssh_any(self, **kwargs):