code: def test_to_str_transcode():
      assert (
          strings.to_str("str", from_enc="ascii") == "str"
          if six.PY2
          else b"str"
      )
      assert (
          strings.to_str("str", from_enc="utf-8") == "str"
          if six.PY2
          else b"str"
      )
  
      assert strings.to_str(
          "юникод".encode("utf-8"), from_enc="utf-8"
      ) == "юникод".encode("utf-8")
      assert strings.to_str(
          "юникод".encode("utf-8"), to_enc="utf-8", from_enc="utf-8"
      ) == "юникод".encode("utf-8")
      assert strings.to_str(
          "юникод".encode("utf-8"), to_enc="cp1251", from_enc="utf-8"
      ) == "юникод".encode("cp1251")
  
      assert strings.to_str(
          "юникод".encode("cp1251"), from_enc="cp1251"
      ) == "юникод".encode("utf-8")
      assert strings.to_str(
          "юникод".encode("cp1251"), to_enc="cp1251", from_enc="cp1251"
      ) == "юникод".encode("cp1251")
      assert strings.to_str(
          "юникод".encode("cp1251"), to_enc="utf-8", from_enc="cp1251"
      ) == "юникод".encode("utf-8")
  
      assert strings.to_str(
          "юникод".encode("koi8-r"), from_enc="koi8-r"
      ) == "юникод".encode("utf-8")
      assert strings.to_str(
          "юникод".encode("koi8-r"), to_enc="koi8-r", from_enc="koi8-r"
      ) == "юникод".encode("koi8-r")
      assert strings.to_str(
          "юникод".encode("koi8-r"), to_enc="cp1251", from_enc="koi8-r"
      ) == "юникод".encode("cp1251")
  
imports: import pytest
  import six
  from library.python import strings
label_desc: Use image node_id 6 for calling a global function with example usage: test_to_str_transcode() without return types