Ejemplo n.º 1
0
    def test_log(self):
        self._caplog.set_level(logging.INFO)
        exc_value = ''
        try:
            raise CoverallsException('Some exception')
        except CoverallsException as e:
            logging.exception('Found exception')
            assert 'raise CoverallsException(' in \
                self._caplog.text
            exc_value = str(e)

        assert exc_value == 'Some exception'
Ejemplo n.º 2
0
def test_finish_exception(mock_log):
    responses.add(responses.POST,
                  'https://coveralls.io/webhook',
                  json={'error': 'Mocked'},
                  status=200)
    expected_json = {'payload': {'status': 'done'}}
    msg = 'Parallel finish failed: Mocked'

    try:
        coveralls.cli.main(argv=['--finish'])
        assert 0 == 1  # Should never reach this line
    except SystemExit:
        pass

    mock_log.assert_has_calls([mock.call(CoverallsException(msg))])
    assert len(responses.calls) == 1
    assert req_json(responses.calls[0].request) == expected_json
Ejemplo n.º 3
0
import json
import os
from unittest import mock

import responses

import coveralls.cli
from coveralls.exception import CoverallsException

EXC = CoverallsException('bad stuff happened')

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
EXAMPLE_DIR = os.path.join(BASE_DIR, 'example')


def req_json(request):
    return json.loads(request.body.decode('utf-8'))


@mock.patch.dict(os.environ, {'TRAVIS': 'True'}, clear=True)
@mock.patch.object(coveralls.cli.log, 'info')
@mock.patch.object(coveralls.Coveralls, 'wear')
def test_debug(mock_wear, mock_log):
    coveralls.cli.main(argv=['debug'])
    mock_wear.assert_called_with(dry_run=True)
    mock_log.assert_has_calls([mock.call('Testing coveralls-python...')])


@mock.patch.dict(os.environ, clear=True)
@mock.patch.object(coveralls.cli.log, 'info')
@mock.patch.object(coveralls.Coveralls, 'wear')
Ejemplo n.º 4
0
 def test_ne(self):
     exc1 = CoverallsException('Value1')
     exc2 = CoverallsException('Value2')
     assert exc1 != exc2
     assert exc1 is not exc2
Ejemplo n.º 5
0
 def test_eq(self):
     exc1 = CoverallsException('Value1')
     exc2 = CoverallsException('Value1')
     assert exc1 == exc2
     assert not exc1 == 35  # pylint: disable=unneeded-not
     assert exc1 is not exc2