Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

407
Vistas
Error when using test_client (Flask) - raise ValueError("unknown url type: %r" % self.full_url)

flask application code:

# main.py 
from flask import Flask, Response
app = Flask(__name__)


@app.route("/", methods=["POST"])
def post_example():
    return Response("aaa")

and this is my testing code:

# e2e.py
from main import app

test_client = app.test_client()


def test_flask_api_call():
    response = test_client.post("/", {"a": "b"})
    pass

I keep receiving:

raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: '://%7B%27a%27:%20%27b%27%7D/'
   
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The problem is on the post method call. You have to name your data arguments client.post("/", data={"a": "b"}), if it's not the case it is considered as a part of the URL.

urllib.parse.quote("/" + str({"a": "b"}))
# '/%7B%27a%27%3A%20%27b%27%7D'

Here is the test code rewritten to define a fixture for the client initialization. More info on testing flask application on the official doc.

import pytest

from main import app


@pytest.fixture(scope="module")
def client():
    with app.test_client() as client:
        yield client


def test_flask_api_call(client):
    response = client.post("/", data={"a": "b"})
    assert response.status_code == 200, f"Got bad status code {response.status_code}"
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda