bpo-44984: Rewrite test_null_strings in _testcapi (GH-27904)
Test also PyObject_Repr(NULL) and PyObject_Bytes(NULL).
(cherry picked from commit 4d689173861257c69adc6dc1dca4171946ddb57f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index f9c5aca..5f78c33 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -619,6 +619,18 @@ def test_fatal_error(self):
''')
self.check_fatal_error(code, expected)
+ def test_pyobject_repr_from_null(self):
+ s = _testcapi.pyobject_repr_from_null()
+ self.assertEqual(s, '<NULL>')
+
+ def test_pyobject_str_from_null(self):
+ s = _testcapi.pyobject_str_from_null()
+ self.assertEqual(s, '<NULL>')
+
+ def test_pyobject_bytes_from_null(self):
+ s = _testcapi.pyobject_bytes_from_null()
+ self.assertEqual(s, b'<NULL>')
+
class TestPendingCalls(unittest.TestCase):