urlmatch: Fix equality with non-UrlPattern types

This commit is contained in:
Florian Bruhin 2018-02-20 06:47:04 +01:00
parent 685e3ffcfe
commit 63c77a4d76
2 changed files with 6 additions and 0 deletions

View File

@ -104,6 +104,8 @@ class UrlPattern:
return hash(self._to_tuple())
def __eq__(self, other):
if not isinstance(other, UrlPattern):
return NotImplemented
# pylint: disable=protected-access
return self._to_tuple() == other._to_tuple()

View File

@ -519,6 +519,10 @@ def test_equal(text1, text2, equal):
assert (hash(pat1) == hash(pat2)) == equal
def test_equal_string():
assert urlmatch.UrlPattern("<all_urls>") != '<all_urls>'
def test_repr():
pat = urlmatch.UrlPattern('https://www.example.com/')
expected = ("qutebrowser.utils.urlmatch.UrlPattern("