mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
merge
This commit is contained in:
commit
79cae680a3
2 changed files with 10 additions and 0 deletions
|
|
@ -1198,9 +1198,13 @@ class Namespace(_AttributeHolder):
|
|||
setattr(self, name, kwargs[name])
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Namespace):
|
||||
return NotImplemented
|
||||
return vars(self) == vars(other)
|
||||
|
||||
def __ne__(self, other):
|
||||
if not isinstance(other, Namespace):
|
||||
return NotImplemented
|
||||
return not (self == other)
|
||||
|
||||
def __contains__(self, key):
|
||||
|
|
|
|||
|
|
@ -4551,6 +4551,12 @@ class TestNamespace(TestCase):
|
|||
self.assertTrue(ns2 != ns3)
|
||||
self.assertTrue(ns2 != ns4)
|
||||
|
||||
def test_equality_returns_notimplemeted(self):
|
||||
# See issue 21481
|
||||
ns = argparse.Namespace(a=1, b=2)
|
||||
self.assertIs(ns.__eq__(None), NotImplemented)
|
||||
self.assertIs(ns.__ne__(None), NotImplemented)
|
||||
|
||||
|
||||
# ===================
|
||||
# File encoding tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue