<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Revisions
import requests

from unittest import mock


class Revisions(object):
  def __init__(self):
    self._req_get = requests.get

  def __enter__(self):
    self.start()
    return self

  def __exit__(self, *args):
    self.stop()

  def _get_patch(self, *a, **kwa):
    return self._req_get(*a, **kwa)

  def start(self):
    def on_get(*a, **kwa):
      return self._get_patch(*a, **kwa)

    self._patcher = mock.patch('requests.get', on_get)
    self._patcher.start()

  def stop(self):
    self._patcher.stop()
<commit_msg>+ Fixed Unittest Mock errors<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Revisions
import requests

try:
  from unittest import mock
except ImportError:
  import mock


class Revisions(object):
  def __init__(self):
    self._req_get = requests.get

  def __enter__(self):
    self.start()
    return self

  def __exit__(self, *args):
    self.stop()

  def _get_patch(self, *a, **kwa):
    return self._req_get(*a, **kwa)

  def start(self):
    def on_get(*a, **kwa):
      return self._get_patch(*a, **kwa)

    self._patcher = mock.patch('requests.get', on_get)
    self._patcher.start()

  def stop(self):
    self._patcher.stop()

{'fraction_non_alphanumeric': 0.1509584664536741, 'fraction_numerical': 0.001597444089456869, 'mean_word_length': 3.320689655172414, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3901811', 'n_tokens_mistral': 462, 'n_tokens_neox': 438, 'n_words': 105}