Beispiel #1
0
async def test_invalid_json(caplog):
    """Test trying to return invalid JSON."""
    view = HomeAssistantView()

    with pytest.raises(HTTPInternalServerError):
        view.json(float("NaN"))

    assert str(float("NaN")) in caplog.text
Beispiel #2
0
async def test_invalid_json(caplog):
    """Test trying to return invalid JSON."""
    view = HomeAssistantView()

    with pytest.raises(HTTPInternalServerError):
        view.json(rb"\ud800")

    assert "Unable to serialize to JSON" in caplog.text
async def test_invalid_json(caplog):
    """Test trying to return invalid JSON."""
    view = HomeAssistantView()

    with pytest.raises(HTTPInternalServerError):
        view.json(object)

    assert str(object) in caplog.text
Beispiel #4
0
async def test_nan_serialized_to_null(caplog):
    """Test nan serialized to null JSON."""
    view = HomeAssistantView()
    response = view.json(float("NaN"))
    assert json.loads(response.body.decode("utf-8")) is None