<commit_before>import httplib

import httpexceptor

from StringIO import StringIO


def mock_response(error=None, message=None):
    responses = []
    environ = {'wsgi.errors': StringIO()}

    def start_response_mock(status, headers, exc_info=None):
        responses.append((status, dict(headers)))

    def app(environ, start_response):
        if error:
            exception_class = getattr(httpexceptor, 'HTTP%s' % error)
            raise exception_class(message or 'error message')
        else:
            start_response('200 OK', [('Content-Type', 'text/plain')])
            return ['no errors']

    # register middleware
    app = httpexceptor.HTTPExceptor(app)

    body = app(environ, start_response_mock)
    return responses[0][0], responses[0][1], body


def test_no_errors():
    status, headers, body = mock_response()

    assert status == _status(200)
    assert len(headers) == 1
    assert headers['Content-Type'] == 'text/plain'
    assert body == ['no errors']


def test_302():
    status, headers, body = mock_response(302, 'http://example.org')

    assert status == _status(302)
    assert len(headers) == 1
    assert headers['Location'] == 'http://example.org'
    assert body == ['']


def test_303():
    status, headers, body = mock_response(303, 'http://example.org')

    assert status == _status(303)
    assert len(headers) == 1
    assert headers['Location'] == 'http://example.org'
    assert body == ['']


def test_304():
    status, headers, body = mock_response(304, '123abc')

    assert status == _status(304)
    assert len(headers) == 1
    assert headers['ETag'] == '123abc'
    assert body == ['']


def test_400():
    status, headers, body = mock_response(400)

    assert status == _status(400)
    assert len(headers) == 1
    assert headers['Content-Type'] == 'text/plain; charset=UTF-8'
    assert body == ['400 Bad Request: error message']


def test_401():
    status, headers, body = mock_response(401, 'login')

    assert status == _status(401)
    assert len(headers) == 1
    assert headers['WWW-Authenticate'] == 'login'
    assert body == ['']


def test_403():<commit_msg>Correct test to be alignment with case<commit_after>import httplib

import httpexceptor

from StringIO import StringIO


def mock_response(error=None, message=None):
    responses = []
    environ = {'wsgi.errors': StringIO()}

    def start_response_mock(status, headers, exc_info=None):
        responses.append((status, dict(headers)))

    def app(environ, start_response):
        if error:
            exception_class = getattr(httpexceptor, 'HTTP%s' % error)
            raise exception_class(message or 'error message')
        else:
            start_response('200 OK', [('Content-Type', 'text/plain')])
            return ['no errors']

    # register middleware
    app = httpexceptor.HTTPExceptor(app)

    body = app(environ, start_response_mock)
    return responses[0][0], responses[0][1], body


def test_no_errors():
    status, headers, body = mock_response()

    assert status == _status(200)
    assert len(headers) == 1
    assert headers['Content-Type'] == 'text/plain'
    assert body == ['no errors']


def test_302():
    status, headers, body = mock_response(302, 'http://example.org')

    assert status == _status(302)
    assert len(headers) == 1
    assert headers['Location'] == 'http://example.org'
    assert body == ['']


def test_303():
    status, headers, body = mock_response(303, 'http://example.org')

    assert status == _status(303)
    assert len(headers) == 1
    assert headers['Location'] == 'http://example.org'
    assert body == ['']


def test_304():
    status, headers, body = mock_response(304, '123abc')

    assert status == _status(304)
    assert len(headers) == 1
    assert headers['etag'] == '123abc'
    assert body == ['']


def test_400():
    status, headers, body = mock_response(400)

    assert status == _status(400)
    assert len(headers) == 1
    assert headers['Content-Type'] == 'text/plain; charset=UTF-8'
    assert body == ['400 Bad Request: error message']


def test_401():
    status, headers, body = mock_response(401, 'login')

    assert status == _status(401)
    assert len(headers) == 1
    assert headers['WWW-Authenticate'] == 'login'
    assert body == ['']


def test_403():
{'fraction_non_alphanumeric': 0.14488042721151614, 'fraction_numerical': 0.034362665428372415, 'mean_word_length': 3.400408580183861, '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': '1602393', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1288, 'n_words': 345}