docstr: Test PyUnicode_Replace()
docstr_tok: ["Test","PyUnicode_Replace","(",")"]
code: def test_replace(self):
      """Test PyUnicode_Replace()"""
      from _testcapi import unicode_replace as replace
  
      str = "abracadabra"
      self.assertEqual(replace(str, "a", "="), "=br=c=d=br=")
      self.assertEqual(replace(str, "a", "<>"), "<>br<>c<>d<>br<>")
      self.assertEqual(replace(str, "abra", "="), "=cad=")
      self.assertEqual(replace(str, "a", "=", 2), "=br=cadabra")
      self.assertEqual(replace(str, "a", "=", 0), str)
      self.assertEqual(
          replace(str, "a", "=", PY_SSIZE_T_MAX), "=br=c=d=br="
      )
      self.assertEqual(replace(str, "a", "=", -1), "=br=c=d=br=")
      self.assertEqual(
          replace(str, "a", "=", PY_SSIZE_T_MIN), "=br=c=d=br="
      )
      self.assertEqual(replace(str, "z", "="), str)
      self.assertEqual(replace(str, "", "="), "=a=b=r=a=c=a=d=a=b=r=a=")
      self.assertEqual(replace(str, "a", "ж"), "жbrжcжdжbrж")
      self.assertEqual(
          replace("абабагаламага", "а", "="), "=б=б=г=л=м=г="
      )
      self.assertEqual(
          replace("Баден-Баден", "Баден", "Baden"), "Baden-Baden"
      )
      # bad arguments
      self.assertRaises(TypeError, replace, "a", "a", b"=")
      self.assertRaises(TypeError, replace, "a", b"a", "=")
      self.assertRaises(TypeError, replace, b"a", "a", "=")
      self.assertRaises(TypeError, replace, "a", "a", ord("="))
      self.assertRaises(TypeError, replace, "a", ord("a"), "=")
      self.assertRaises(TypeError, replace, [], "a", "=")
  
imports: import unittest
  import sys
  from test import support
  from test.support import import_helper
label_desc: Use image node_id 39 for calling the CAPITest obj's underlying member method code with example usage: obj.test_replace() without return types