Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

398
Views
Error al usar test_client (Flask) - aumentar ValueError("tipo de URL desconocido: %r" % self.full_url)

código de aplicación del matraz:

 # main.py from flask import Flask, Response app = Flask(__name__) @app.route("/", methods=["POST"]) def post_example(): return Response("aaa")

y este es mi código de prueba:

 # e2e.py from main import app test_client = app.test_client() def test_flask_api_call(): response = test_client.post("/", {"a": "b"}) pass

sigo recibiendo:

 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 answers
Answer question

0

El problema está en la llamada al método de post . Debe nombrar sus argumentos de datos client.post("/", data={"a": "b"}) , si no es el caso, se considera como parte de la URL.

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

Aquí está el código de prueba reescrito para definir un fixture para la inicialización del cliente. Más información sobre la aplicación del matraz de prueba en el documento oficial .

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!