<commit_before>module ActiveSupport
  module Testing
    module SetupAndTeardown
      # For compatibility with Ruby < 1.8.6
      PASSTHROUGH_EXCEPTIONS =
        if defined?(Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS)
          Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
        else
          [NoMemoryError, SignalException, Interrupt, SystemExit]
        end

      def self.included(base)
        base.class_eval do
          include ActiveSupport::Callbacks
          define_callbacks :setup, :teardown

          if defined?(::Mini)
            alias_method :run, :run_with_callbacks_and_miniunit
          else
            begin
              gem 'mocha'
              alias_method :run, :run_with_callbacks_and_mocha
            rescue Gem::LoadError
              alias_method :run, :run_with_callbacks_and_testunit
            end
          end
        end
      end

      def run_with_callbacks_and_miniunit(runner)<commit_msg>Revert "Check for mocha gem without requiring the lib.  [#403 state:resolved]"<commit_after>module ActiveSupport
  module Testing
    module SetupAndTeardown
      # For compatibility with Ruby < 1.8.6
      PASSTHROUGH_EXCEPTIONS =
        if defined?(Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS)
          Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
        else
          [NoMemoryError, SignalException, Interrupt, SystemExit]
        end

      def self.included(base)
        base.class_eval do
          include ActiveSupport::Callbacks
          define_callbacks :setup, :teardown

          if defined?(::Mini)
            alias_method :run, :run_with_callbacks_and_miniunit
          else
            begin
              require 'mocha'
              alias_method :run, :run_with_callbacks_and_mocha
            rescue LoadError
              alias_method :run, :run_with_callbacks_and_testunit
            end
          end
        end
      end

      def run_with_callbacks_and_miniunit(runner)
{'fraction_non_alphanumeric': 0.0609007164790174, 'fraction_numerical': 0.004605936540429887, 'mean_word_length': 2.2101806239737276, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6959673', 'n_tokens_mistral': 591, 'n_tokens_neox': 544, 'n_words': 115}