code: def test_invalid_required(self, env):
      env = Environment(
          loader=DictLoader(
              {
                  "default": "{% block x required %}data {# #}{% endblock %}",
                  "default1": "{% block x required %}{% block y %}"
                  "{% endblock %}  {% endblock %}",
                  "default2": "{% block x required %}{% if true %}"
                  "{% endif %}  {% endblock %}",
                  "level1": "{% if default %}{% extends default %}"
                  "{% else %}{% extends 'default' %}{% endif %}"
                  "{%- block x %}CHILD{% endblock %}",
              }
          )
      )
      t = env.get_template("level1")
  
      with pytest.raises(
          TemplateSyntaxError,
          match="Required blocks can only contain comments or whitespace",
      ):
          assert t.render(default="default")
          assert t.render(default="default2")
          assert t.render(default="default3")
  
imports: import pytest
  from jinja2 import DictLoader
  from jinja2 import Environment
  from jinja2 import TemplateRuntimeError
  from jinja2 import TemplateSyntaxError
label_desc: Use image node_id 18 for calling the TestInheritance obj's underlying member method code with example usage: obj.test_invalid_required(env) without return types