Example #1
0
 def test_detects_python2(self):
     with patch.object(sys, 'version_info', (2, 7, 11)):
         conn = backends.BaseConnection('localhost',
                                        sudo=False,
                                        eager=False)
         conn_string = conn._make_connection_string(
             'localhost', _needs_ssh=lambda x: True)
         assert conn_string == 'ssh=localhost//python=python2'
Example #2
0
 def test_makes_python_with_ssh(self):
     conn = backends.BaseConnection('localhost',
                                    sudo=False,
                                    eager=False,
                                    interpreter='python')
     conn_string = conn._make_connection_string('localhost',
                                                _needs_ssh=lambda x: True)
     assert conn_string == 'ssh=localhost//python=python'
Example #3
0
 def test_makes_sudo_python_no_ssh(self):
     conn = backends.BaseConnection('localhost',
                                    sudo=True,
                                    eager=False,
                                    interpreter='python')
     conn_string = conn._make_connection_string('localhost',
                                                _needs_ssh=lambda x: False)
     assert conn_string == 'popen//python=sudo python'
Example #4
0
 def test_ssh_is_forced(self):
     conn = backends.BaseConnection('localhost',
                                    sudo=False,
                                    eager=False,
                                    use_ssh=True,
                                    interpreter='python')
     conn_string = conn._make_connection_string('localhost',
                                                _needs_ssh=lambda x: False)
     assert conn_string == 'ssh=localhost//python=python'
Example #5
0
 def test_makes_sudo_python_with_ssh_options(self):
     conn = backends.BaseConnection('localhost',
                                    sudo=True,
                                    eager=False,
                                    interpreter='python',
                                    ssh_options='-F vagrant_ssh_config')
     conn_string = conn._make_connection_string('localhost',
                                                _needs_ssh=lambda x: True)
     assert conn_string == 'ssh=-F vagrant_ssh_config localhost//python=sudo python'
Example #6
0
 def test_does_need_sudo(self):
     self.execnet.receive.return_value = 'alfredo'
     conn = backends.BaseConnection('localhost', sudo=True, eager=False)
     assert conn._detect_sudo(_execnet=self.execnet) is True
Example #7
0
 def test_detects_python3(self):
     with patch.object(sys, 'version_info', (3, 5, 1)):
         conn = backends.BaseConnection('localhost', sudo=True, eager=False)
         conn_string = conn._make_connection_string('localhost', _needs_ssh=lambda x: False)
         assert conn_string == 'popen//python=sudo python3'
Example #8
0
 def setup(self):
     self.conn = backends.BaseConnection('localhost', sudo=True, eager=False)
     self.gateway = FakeGateway()
     self.conn.gateway = self.gateway