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

from __future__ import with_statement

import time
import cookielib
import os
import unittest

import requests
import envoy

try:
    import omnijson as json
except ImportError:
    import json


# TODO: Detect an open port.
PORT = os.environ.get('HTTPBIN_PORT', '7077')

HTTPBIN_URL = 'http://0.0.0.0:%s/' % (PORT)
# HTTPBIN_URL = 'http://127.0.0.1:8000/'


def httpbin(*suffix):
    """Returns url for HTTPBIN resource."""

    return HTTPBIN_URL + '/'.join(suffix)


SERVICES = (httpbin, )

_httpbin = False

class RequestsTestSuite(unittest.TestCase):
    """Requests test cases."""

    # It goes to eleven.
    _multiprocess_can_split_ = True

    def setUp(self):

        global _httpbin

        if not _httpbin:

            c = envoy.connect('gunicorn httpbin:app --bind=0.0.0.0:%s' % (PORT))

            self.httpbin = c
            _httpbin = True
            time.sleep(1)



    def tearDown(self):
        """Teardown."""
        # self.httpbin.kill()


    def test_invalid_url(self):
        self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')


    def test_HTTP_200_OK_GET(self):
        r = requests.get(httpbin('/get'))
        self.assertEqual(r.status_code, 200)

    def test_HTTP_302_ALLOW_REDIRECT_GET(self):
	r = requests.get(httpbin('redirect', '1'))
	self.assertEqual(r.status_code, 200)

    def test_HTTP_302_GET(self):
	r = requests.get(httpbin('redirect', '1'), allow_redirects=False)
	self.assertEqual(r.status_code, 302)


    def test_HTTP_200_OK_GET_WITH_PARAMS(self):
        heads = {'User-agent': 'Mozilla/5.0'}

        r = requests.get(httpbin('user-agent'), headers=heads)

        assert heads['User-agent'] in r.content<commit_msg>I don't even want to know.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import with_statement

import time
import cookielib
import os
import unittest

import requests
import envoy

try:
    import omnijson as json
except ImportError:
    import json


# TODO: Detect an open port.
PORT = os.environ.get('HTTPBIN_PORT', '7077')

HTTPBIN_URL = 'http://0.0.0.0:%s/' % (PORT)
# HTTPBIN_URL = 'http://127.0.0.1:8000/'


def httpbin(*suffix):
    """Returns url for HTTPBIN resource."""

    return HTTPBIN_URL + '/'.join(suffix)


SERVICES = (httpbin, )

_httpbin = False

class RequestsTestSuite(unittest.TestCase):
    """Requests test cases."""

    # It goes to eleven.
    _multiprocess_can_split_ = True

    def setUp(self):

        global _httpbin

        if not _httpbin:

            c = envoy.connect('gunicorn httpbin:app --bind=0.0.0.0:%s' % (PORT))

            self.httpbin = c
            _httpbin = True
            time.sleep(1)



    def tearDown(self):
        """Teardown."""
        # self.httpbin.kill()


    def test_invalid_url(self):
        self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')


    def test_HTTP_200_OK_GET(self):
        r = requests.get(httpbin('/get'))
        self.assertEqual(r.status_code, 200)

    def test_HTTP_302_ALLOW_REDIRECT_GET(self):
        r = requests.get(httpbin('redirect', '1'))
        self.assertEqual(r.status_code, 200)

    def test_HTTP_302_GET(self):
        r = requests.get(httpbin('redirect', '1'), allow_redirects=False)
        self.assertEqual(r.status_code, 302)


    def test_HTTP_200_OK_GET_WITH_PARAMS(self):
        heads = {'User-agent': 'Mozilla/5.0'}

        r = requests.get(httpbin('user-agent'), headers=heads)

        assert heads['User-agent'] in r.content
{'fraction_non_alphanumeric': 0.1347617705102904, 'fraction_numerical': 0.02762898223851142, 'mean_word_length': 2.964245810055866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '3576097', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1198, 'n_words': 256}