code: def test_bytes_to_string():
      """Tests the ability to pass bytes to C++ string-accepting functions.  Note that this is
      one-way: the only way to return bytes to Python is via the pybind11::bytes class.
      """
      # Issue #816
  
      assert m.strlen(b"hi") == 2
      assert m.string_length(b"world") == 5
      assert m.string_length("a\x00b".encode()) == 3
      assert m.strlen("a\x00b".encode()) == 1  # C-string limitation
  
      # passing in a utf8 encoded string should work
      assert m.string_length("💩".encode()) == 4
  
imports: import sys
  import pytest
  import env
  from pybind11_tests import IncType, UserType
  from pybind11_tests import builtin_casters
label_desc: Use image node_id 4 for calling a global function with example usage: test_bytes_to_string() without return types