<commit_before>import pytest

from starlette.exceptions import ExceptionMiddleware, HTTPException
from starlette.responses import PlainTextResponse
from starlette.routing import Route, Router, WebSocketRoute
from starlette.testclient import TestClient


def raise_runtime_error(request):
    raise RuntimeError("Yikes")


def not_acceptable(request):
    raise HTTPException(status_code=406)


def not_modified(request):
    raise HTTPException(status_code=304)


class HandledExcAfterResponse:
    def __init__(self, scope):
        pass

    async def __call__(self, receive, send):
        response = PlainTextResponse("OK", status_code=200)
        await response(receive, send)
        raise HTTPException(status_code=406)


router = Router(
    routes=[
        Route("/runtime_error", endpoint=raise_runtime_error),
        Route("/not_acceptable", endpoint=not_acceptable),
        Route("/not_modified", endpoint=not_modified),
        Route("/handled_exc_after_response", endpoint=HandledExcAfterResponse),
        WebSocketRoute("/runtime_error", endpoint=raise_runtime_error),
    ]
)


app = ExceptionMiddleware(router)
client = TestClient(app)


# def test_server_error():
#     with pytest.raises(RuntimeError):
#         response = client.get("/runtime_error")
#
#     allow_500_client = TestClient(app, raise_server_exceptions=False)
#     response = allow_500_client.get("/runtime_error")
#     assert response.status_code == 500
#     assert response.text == "Internal Server Error"


# def test_debug_enabled():
#     app = ExceptionMiddleware(router)
#     app.debug = True
#     allow_500_client = TestClient(app, raise_server_exceptions=False)
#     response = allow_500_client.get("/runtime_error")
#     assert response.status_code == 500
#     assert "RuntimeError" in response.text


def test_not_acceptable():
    response = client.get("/not_acceptable")
    assert response.status_code == 406
    assert response.text == "Not Acceptable"


def test_not_modified():<commit_msg>Remove redundant test cases<commit_after>import pytest

from starlette.exceptions import ExceptionMiddleware, HTTPException
from starlette.responses import PlainTextResponse
from starlette.routing import Route, Router, WebSocketRoute
from starlette.testclient import TestClient


def raise_runtime_error(request):
    raise RuntimeError("Yikes")


def not_acceptable(request):
    raise HTTPException(status_code=406)


def not_modified(request):
    raise HTTPException(status_code=304)


class HandledExcAfterResponse:
    def __init__(self, scope):
        pass

    async def __call__(self, receive, send):
        response = PlainTextResponse("OK", status_code=200)
        await response(receive, send)
        raise HTTPException(status_code=406)


router = Router(
    routes=[
        Route("/runtime_error", endpoint=raise_runtime_error),
        Route("/not_acceptable", endpoint=not_acceptable),
        Route("/not_modified", endpoint=not_modified),
        Route("/handled_exc_after_response", endpoint=HandledExcAfterResponse),
        WebSocketRoute("/runtime_error", endpoint=raise_runtime_error),
    ]
)


app = ExceptionMiddleware(router)
client = TestClient(app)


def test_not_acceptable():
    response = client.get("/not_acceptable")
    assert response.status_code == 406
    assert response.text == "Not Acceptable"


def test_not_modified():
{'fraction_non_alphanumeric': 0.0963533946042099, 'fraction_numerical': 0.014230655203083309, 'mean_word_length': 4.623333333333333, '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': '3592992', 'n_tokens_mistral': 1001, 'n_tokens_neox': 940, 'n_words': 203}