code: def test_unsafe(self, env):
      env = SandboxedEnvironment()
      pytest.raises(
          SecurityError,
          env.from_string("{{ foo.foo() }}").render,
          foo=PrivateStuff(),
      )
      assert (
          env.from_string("{{ foo.bar() }}").render(foo=PrivateStuff())
          == "23"
      )
  
      pytest.raises(
          SecurityError,
          env.from_string("{{ foo._foo() }}").render,
          foo=PublicStuff(),
      )
      assert (
          env.from_string("{{ foo.bar() }}").render(foo=PublicStuff())
          == "23"
      )
      assert env.from_string("{{ foo.__class__ }}").render(foo=42) == ""
      assert (
          env.from_string("{{ foo.func_code }}").render(
              foo=lambda: None
          )
          == ""
      )
      # security error comes from __class__ already.
      pytest.raises(
          SecurityError,
          env.from_string(
              "{{ foo.__class__.__subclasses__() }}"
          ).render,
          foo=42,
      )
  
imports: import pytest
  from jinja2 import Environment
  from jinja2 import escape
  from jinja2 import Markup
  from jinja2._compat import text_type
  from jinja2.exceptions import SecurityError
  from jinja2.exceptions import TemplateRuntimeError
  from jinja2.exceptions import TemplateSyntaxError
  from jinja2.nodes import EvalContext
  from jinja2.sandbox import ImmutableSandboxedEnvironment
  from jinja2.sandbox import SandboxedEnvironment
  from jinja2.sandbox import unsafe
label_desc: Use image node_id 1 for calling the TestSandbox obj's underlying member method code with example usage: obj.test_unsafe(env) without return types