<commit_before>from .. import monkey; monkey.patch_all()

from nose.tools import eq_ as eq
from cStringIO import StringIO

import os
import nose

from .. import connection, run

from .util import assert_raises

def setup():
    try:
        host = os.environ['ORCHESTRA_TEST_HOST']
    except KeyError:
        raise nose.SkipTest(
            'To run integration tests, set environment '
            + 'variable ORCHESTRA_TEST_HOST to user@host to use.',
            )
    global HOST
    HOST = host

def test_crash():
    ssh = connection.connect(HOST)
    e = assert_raises(
        run.CommandCrashedError,
        run.run,
        client=ssh,
        args=['sh', '-c', 'kill -ABRT $$'],
        )
    eq(e.command, "sh -c 'kill -ABRT $$'")
    eq(str(e), "Command crashed: \"sh -c 'kill -ABRT $$'\"")

def test_lost():
    ssh = connection.connect(HOST)
    e = assert_raises(
        run.ConnectionLostError,
        run.run,
        client=ssh,
        args=['sh', '-c', 'kill -ABRT $PPID'],<commit_msg>Pyflakes cleanup.<commit_after>from .. import monkey; monkey.patch_all()

from nose.tools import eq_ as eq
from cStringIO import StringIO

import os
import nose

from .. import connection, run

from .util import assert_raises

HOST = None

def setup():
    try:
        host = os.environ['ORCHESTRA_TEST_HOST']
    except KeyError:
        raise nose.SkipTest(
            'To run integration tests, set environment '
            + 'variable ORCHESTRA_TEST_HOST to user@host to use.',
            )
    global HOST
    HOST = host

def test_crash():
    ssh = connection.connect(HOST)
    e = assert_raises(
        run.CommandCrashedError,
        run.run,
        client=ssh,
        args=['sh', '-c', 'kill -ABRT $$'],
        )
    eq(e.command, "sh -c 'kill -ABRT $$'")
    eq(str(e), "Command crashed: \"sh -c 'kill -ABRT $$'\"")

def test_lost():
    ssh = connection.connect(HOST)
    e = assert_raises(
        run.ConnectionLostError,
        run.run,
        client=ssh,
        args=['sh', '-c', 'kill -ABRT $PPID'],
{'fraction_non_alphanumeric': 0.12849435998038253, 'fraction_numerical': 0.0, 'mean_word_length': 2.3387888707037643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7640174', 'n_tokens_mistral': 683, 'n_tokens_neox': 658, 'n_words': 182}