mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
0fd97e46c7
commit
5580f31c56
7 changed files with 107 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue