diff options
author | Nico Mexis <nico.mexis@kabelmail.de> | 2024-08-10 19:16:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-10 19:16:34 (GMT) |
commit | 5580f31c56e6f90909bdceddda077504cc2d18b0 (patch) | |
tree | 5ca58367cfef11b9bed9430db22378071f6a9029 /Lib/test/test_operator.py | |
parent | 0fd97e46c75bb3060485b796ca597b13af7e6bec (diff) | |
download | cpython-5580f31c56e6f90909bdceddda077504cc2d18b0.zip cpython-5580f31c56e6f90909bdceddda077504cc2d18b0.tar.gz cpython-5580f31c56e6f90909bdceddda077504cc2d18b0.tar.bz2 |
gh-115808: Add ``is_none`` and ``is_not_none`` to ``operator`` (#115814)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Diffstat (limited to 'Lib/test/test_operator.py')
-rw-r--r-- | Lib/test/test_operator.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index f8eac8d..812d464 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -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: |