old_contents: import re
  
  from graphql.utilities import get_introspection_query
  
  
  def describe_get_introspection_query():
      def skips_all_description_fields():
          has_descriptions = re.compile(r"\bdescription\b").search
  
          assert has_descriptions(get_introspection_query())
  
          assert has_descriptions(get_introspection_query(descriptions=True))
  
          assert not has_descriptions(get_introspection_query(descriptions=False))
  
      def includes_is_repeatable_field_on_directives():
          has_repeatability = re.compile(r"\bisRepeatable\b").search
  
          assert not has_repeatability(get_introspection_query())
  
          assert has_repeatability(get_introspection_query(directive_is_repeatable=True))
  
          assert not has_repeatability(
              get_introspection_query(directive_is_repeatable=False)
          )
  
      def includes_description_field_on_schema():
          all_descriptions = re.compile(r"\bdescription\b").findall
  
          assert len(all_descriptions(get_introspection_query())) == 5
  
          assert (
              len(all_descriptions(get_introspection_query(schema_description=False)))
              == 5
          )
  
          assert (
              len(all_descriptions(get_introspection_query(schema_description=True))) == 6
          )
  
          assert not all_descriptions(
              get_introspection_query(descriptions=False, schema_description=True)
          )
  
      def includes_specified_by_url_field():
          all_specified_by_urls = re.compile(r"\bspecifiedByUrl\b").findall
  
          assert not all_specified_by_urls(get_introspection_query())
  
          assert not all_specified_by_urls(
              get_introspection_query(specified_by_url=False)
          )
  
          assert (
              len(all_specified_by_urls(get_introspection_query(specified_by_url=True)))
              == 1
          )
  
new_contents: import re
  
  from typing import Pattern
  
  from graphql.utilities import get_introspection_query
  
  
  class ExcpectIntrospectionQuery:
      def __init__(self, **options):
          self.query = get_introspection_query(**options)
  
      def to_match(self, name: str, times: int = 1) -> None:
          pattern = self.to_reg_exp(name)
          assert len(pattern.findall(self.query)) == times
  
      def to_not_match(self, name: str) -> None:
          pattern = self.to_reg_exp(name)
          assert not pattern.search(self.query)
  
      @staticmethod
      def to_reg_exp(name: str) -> Pattern:
          return re.compile(fr"\b{name}\b")
  
  
  def describe_get_introspection_query():
      def skips_all_description_fields():
          ExcpectIntrospectionQuery().to_match("description", 5)
          ExcpectIntrospectionQuery(descriptions=True).to_match("description", 5)
          ExcpectIntrospectionQuery(descriptions=False).to_not_match("description")
  
      def includes_is_repeatable_field_on_directives():
          ExcpectIntrospectionQuery().to_not_match("isRepeatable")
          ExcpectIntrospectionQuery(directive_is_repeatable=True).to_match("isRepeatable")
          ExcpectIntrospectionQuery(directive_is_repeatable=False).to_not_match(
              "isRepeatable"
          )
  
      def includes_description_field_on_schema():
          ExcpectIntrospectionQuery().to_match("description", 5)
          ExcpectIntrospectionQuery(schema_description=False).to_match("description", 5)
          ExcpectIntrospectionQuery(schema_description=True).to_match("description", 6)
          ExcpectIntrospectionQuery(
              descriptions=False, schema_description=True
          ).to_not_match("description")
  
      def includes_specified_by_url_field():
          ExcpectIntrospectionQuery().to_not_match("specifiedByUrl")
          ExcpectIntrospectionQuery(specified_by_url=True).to_match("specifiedByUrl")
          ExcpectIntrospectionQuery(specified_by_url=False).to_not_match("specifiedByUrl")
  
subject: update get_introspection_query tests to use custom matchers