Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unhashable exception #230

Merged
merged 2 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions coveralls/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ def __eq__(self, other):

def __ne__(self, other):
return not self.__eq__(other)

def __hash__(self):
return hash(str(self))
41 changes: 41 additions & 0 deletions tests/api/exception_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# pylint: disable=no-self-use
import logging
import unittest

import pytest

from coveralls.exception import CoverallsException

class CoverallsExceptionTest(unittest.TestCase):

_caplog = None

@pytest.fixture(autouse=True)
def inject_fixtures(self, caplog):
self._caplog = caplog

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'

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

def test_ne(self):
exc1 = CoverallsException('Value1')
exc2 = CoverallsException('Value2')
assert exc1 != exc2
assert exc1 is not exc2