Skip to content

Commit

Permalink
fix: fix unhashable CoverallsException (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigc committed Jul 8, 2020
1 parent 458e22d commit aa55335
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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

0 comments on commit aa55335

Please sign in to comment.