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

from click.testing import CliRunner
from os.path import abspath, dirname
import pkg_resources
import pytest
import requests
import json

from turnstile.manager_subcommands.upgrade import get_pypi_version, get_packages, upgrade_packages, cmd

TEST_FOLDER = dirname(abspath(__file__))


class FakeResponse:
    def __init__(self, status_code, text):
        self.status_code = status_code
        self.text = text
        self.ok = status_code == 200

    def json(self):
        return json.loads(self.text)


class FakeEntrypoint:
    def __init__(self, version, project_name):
        self.dist = FakeDistribution(version, project_name)


class FakeDistribution:
    def __init__(self, version, project_name):
        self.version = version
        self.project_name = project_name


@pytest.fixture
def fake_pypi(monkeypatch: '_pytest.monkeypatch.monkeypatch'):
    def fake_get(url:str):
        if url == "https://pypi.python.org/pypi/package_1/json":
            return FakeResponse(200, '{"info": {"version": "1.0"}}')
        elif url == "https://pypi.python.org/pypi/package_2/json":
            return FakeResponse(200, '{"info": {"version": "2.0"}}')
        elif url == "https://pypi.python.org/pypi/package_3/json":
            return FakeResponse(200, '{"info": {"version": "2.0"}}')
        elif url == "https://pypi.python.org/pypi/package_4/json":
            return FakeResponse(200, '{"info": {"version": "1.4"}}')
        return url

    monkeypatch.setattr(requests, 'get', fake_get)


@pytest.fixture
def fake_pkg_resources(monkeypatch: '_pytest.monkeypatch.monkeypatch'):
    def fake_iter_entry_points(group):
        if group == 'turnstile.commands':
            return [FakeEntrypoint('1.0', 'package_1')]
        elif group == 'turnstile.pre_commit':<commit_msg>https://github.com/zalando/turnstile/issues/34 Remove annotation in test<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from click.testing import CliRunner
from os.path import abspath, dirname
import pkg_resources
import pytest
import requests
import json

from turnstile.manager_subcommands.upgrade import get_pypi_version, get_packages, upgrade_packages, cmd

TEST_FOLDER = dirname(abspath(__file__))


class FakeResponse:
    def __init__(self, status_code, text):
        self.status_code = status_code
        self.text = text
        self.ok = status_code == 200

    def json(self):
        return json.loads(self.text)


class FakeEntrypoint:
    def __init__(self, version, project_name):
        self.dist = FakeDistribution(version, project_name)


class FakeDistribution:
    def __init__(self, version, project_name):
        self.version = version
        self.project_name = project_name


@pytest.fixture
def fake_pypi(monkeypatch):
    def fake_get(url:str):
        if url == "https://pypi.python.org/pypi/package_1/json":
            return FakeResponse(200, '{"info": {"version": "1.0"}}')
        elif url == "https://pypi.python.org/pypi/package_2/json":
            return FakeResponse(200, '{"info": {"version": "2.0"}}')
        elif url == "https://pypi.python.org/pypi/package_3/json":
            return FakeResponse(200, '{"info": {"version": "2.0"}}')
        elif url == "https://pypi.python.org/pypi/package_4/json":
            return FakeResponse(200, '{"info": {"version": "1.4"}}')
        return url

    monkeypatch.setattr(requests, 'get', fake_get)


@pytest.fixture
def fake_pkg_resources(monkeypatch: '_pytest.monkeypatch.monkeypatch'):
    def fake_iter_entry_points(group):
        if group == 'turnstile.commands':
            return [FakeEntrypoint('1.0', 'package_1')]
        elif group == 'turnstile.pre_commit':
{'fraction_non_alphanumeric': 0.1361439312567132, 'fraction_numerical': 0.017185821697099892, 'mean_word_length': 3.4187425860023724, 'pattern_counts': {'":': 24, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 9, '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': '6939819', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1209, 'n_words': 250}