'Switching users mid-session should not screw up password memory'

@server()
def test_password_memory_on_user_switch(self):

    def _to_user(user):
        return join_host_strings(user, env.host, env.port)
    user1 = 'root'
    user2 = USER
    with settings(hide('everything'), password=None):
        with settings(password_response(PASSWORDS[user1]), host_string=_to_user(user1)):
            run('ls    /simple')
        with settings(password_response(PASSWORDS[user2]), host_string=_to_user(user2)):
            run('ls    /simple')
        with settings(password_response('whatever', times_called=0), host_string=_to_user(user2)):
            sudo('ls    /simple')
