gh-115808: Add `is_none and is_not_none to operator` (#115814)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
Nico Mexis 2024-08-10 21:16:34 +02:00 committed by GitHub
parent 0fd97e46c7
commit 5580f31c56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 107 additions and 3 deletions

View file

@ -347,6 +347,26 @@ class OperatorTestCase:
self.assertFalse(operator.is_not(a, b))
self.assertTrue(operator.is_not(a,c))
def test_is_none(self):
operator = self.module
a = 'xyzpdq'
b = ''
c = None
self.assertRaises(TypeError, operator.is_none)
self.assertFalse(operator.is_none(a))
self.assertFalse(operator.is_none(b))
self.assertTrue(operator.is_none(c))
def test_is_not_none(self):
operator = self.module
a = 'xyzpdq'
b = ''
c = None
self.assertRaises(TypeError, operator.is_not_none)
self.assertTrue(operator.is_not_none(a))
self.assertTrue(operator.is_not_none(b))
self.assertFalse(operator.is_not_none(c))
def test_attrgetter(self):
operator = self.module
class A: