<s> from __future__ import absolute_import , print_function <EOL> import os <EOL> import sys <EOL> import subprocess <EOL> from nose import SkipTest <EOL> from testmill import util <EOL> from testmill . main import main <EOL> from testmill . state import env <EOL> from testmill . test import * <EOL> @ systemtest <EOL> class TestSSH ( TestSuite ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def setup_class ( cls ) : <EOL> args = get_common_args ( ) <EOL> args += [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> with env . new ( ) : <EOL> status = main ( args ) <EOL> if status != <NUM_LIT:0> : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> project , defname , instance = env . application [ '<STR_LIT:name>' ] . split ( '<STR_LIT::>' ) <EOL> appname = '<STR_LIT>' . format ( defname , instance ) <EOL> vms = [ vm [ '<STR_LIT:name>' ] for vm in env . appdef [ '<STR_LIT>' ] ] <EOL> cls . appname = appname <EOL> cls . vms = vms <EOL> def test_openssh ( self ) : <EOL> openssh = util . find_openssh ( ) <EOL> if openssh is None : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> try : <EOL> import pexpect <EOL> except ImportError : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> for vm in self . vms : <EOL> libdir = os . path . join ( testenv . topdir , '<STR_LIT>' ) <EOL> env = os . environ . copy ( ) <EOL> env [ '<STR_LIT>' ] = libdir <EOL> args = [ '<STR_LIT>' ] <EOL> args += get_common_args ( ) <EOL> args += [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , self . appname , vm ] <EOL> child = pexpect . spawn ( sys . executable , args , env = env ) <EOL> child . expect ( '<STR_LIT>' ) <EOL> child . send ( "<STR_LIT>" ) <EOL> child . expect ( r'<STR_LIT>' ) <EOL> child . send ( '<STR_LIT>' ) <EOL> child . expect ( [ pexpect . EOF , pexpect . TIMEOUT ] ) <EOL> def test_paramiko ( self ) : <EOL> for vm in self . vms : <EOL> libdir = os . path . join ( testenv . topdir , '<STR_LIT>' ) <EOL> env = os . environ . copy ( ) <EOL> env [ '<STR_LIT>' ] = libdir <EOL> command = [ sys . executable , '<STR_LIT>' ] <EOL> command += get_common_args ( ) <EOL> command += [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , self . appname , vm ] <EOL> child = subprocess . Popen ( command , env = env , stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , stderr = subprocess . PIPE ) <EOL> script = "<STR_LIT>" <EOL> stdout , stderr = child . communicate ( script ) <EOL> assert '<STR_LIT>' in stdout </s>
