text: import pytest
  
  import strawberry
  from strawberry.extensions import Extension
  
  
  class MyExtension(Extension):
      def get_results(self):
          return {"example": "example"}
  
  
  def test_base_extension():
      global Person
  
      @strawberry.type
      class Person:
          name: str = "Jess"
  
      @strawberry.type
      class Query:
          @strawberry.field
          def person(self) -> Person:
              return Person()
  
      schema = strawberry.Schema(query=Query, extensions=[Extension])
  
      query = """
          query {
              person {
                  name
              }
          }
      """
  
      result = schema.execute_sync(query)
  
      assert not result.errors
  
      assert result.extensions == {}
  
      del Person
  
  
  def test_extension():
      global Person
  
      @strawberry.type
      class Person:
          name: str = "Jess"
  
      @strawberry.type
      class Query:
          @strawberry.field
          def person(self) -> Person:
              return Person()
  
      schema = strawberry.Schema(query=Query, extensions=[MyExtension])
  
      query = """
          query {
              person {
                  name
              }
          }
      """
  
      result = schema.execute_sync(query)
  
      assert not result.errors
  
      assert result.extensions == {
          "example": "example",
      }
  
      del Person
  
  
  @pytest.mark.asyncio
  async def test_extension_async():
      global Person
  
      @strawberry.type
      class Person:
          name: str = "Jess"
  
      @strawberry.type
      class Query:
          @strawberry.field
          async def person(self) -> Person:
              return Person()
  
      schema = strawberry.Schema(query=Query, extensions=[MyExtension])
  
      query = """
          query {
              person {
                  name
              }
          }
      """
  
      result = await schema.execute(query)
  
      assert not result.errors
  
      assert result.extensions == {
          "example": "example",
      }
  
      del Person
  