mirror of https://github.com/scrapy/scrapy.git
Link.__eq__: return NotImplemented instead of raising NotImplementedError (#7611)
This commit is contained in:
parent
b08ed1cf05
commit
983e6c1182
|
|
@ -39,7 +39,7 @@ class Link:
|
||||||
|
|
||||||
def __eq__(self, other: object) -> bool:
|
def __eq__(self, other: object) -> bool:
|
||||||
if not isinstance(other, Link):
|
if not isinstance(other, Link):
|
||||||
raise NotImplementedError
|
return NotImplemented
|
||||||
return (
|
return (
|
||||||
self.url == other.url
|
self.url == other.url
|
||||||
and self.text == other.text
|
and self.text == other.text
|
||||||
|
|
|
||||||
|
|
@ -55,3 +55,7 @@ class TestLink:
|
||||||
def test_bytes_url(self):
|
def test_bytes_url(self):
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
Link(b"http://www.example.com/\xc2\xa3")
|
Link(b"http://www.example.com/\xc2\xa3")
|
||||||
|
|
||||||
|
def test_eq_non_link(self):
|
||||||
|
url = "http://example.com"
|
||||||
|
assert Link(url) != url
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue