Added __ne__ operator support for Country object, fixes #45

This commit is contained in:
Konsta Vesterinen
2013-10-18 10:33:35 +03:00
parent 2db52db447
commit 4125403b73
3 changed files with 9 additions and 0 deletions

View File

@@ -272,6 +272,8 @@ API Documentation
.. autofunction:: sort_query
.. autofunction:: escape_like
.. autofunction:: naturally_equivalent
.. autofunction:: has_changes
.. autofunction:: non_indexed_foreign_keys
.. autofunction:: is_indexed_foreign_key
.. autofunction:: identity

View File

@@ -23,6 +23,9 @@ class Country(object):
else:
return NotImplemented
def __ne__(self, other):
return not (self == other)
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.code)

View File

@@ -22,6 +22,10 @@ class TestCountry(object):
assert u'fi' == Country(u'fi')
assert Country(u'fi') == Country(u'fi')
def test_non_equality_operator(self):
assert Country(u'fi') != u'sv'
assert not (Country(u'fi') != u'fi')
class TestCountryType(TestCase):
def create_models(self):