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

916
Views
Pytest Flask, error 308 Redirección permanente al iniciar sesión

Quiero probar mi aplicación, aquí está el código de prueba:

 import sys import pytest from flask_simplelogin import SimpleLogin sys.path.insert(1, '') from app import app as myapp #--------------------------------------------------- #SETUP #--------------------------------------------------- myapp.config['SECRET_KEY'] = 'something-secret' myapp.config['SIMPLELOGIN_USERNAME'] = 'admin' myapp.config['SIMPLELOGIN_PASSWORD'] = 'secret' SimpleLogin(myapp) @pytest.fixture def app(): return myapp @pytest.fixture def setup_url(): return "http://127.0.0.1:8080/" def login(client): return client.post("http://127.0.0.1:8080/login", data=dict( username="admin", password="secret" )) #--------------------------------------------------- #TESTS #--------------------------------------------------- def test_get_list_campagne(client,setup_url): resp = login(client) assert resp.status_code==200 resp = client.get("/Campagne") assert resp.status_code==200

Pero devuelve una redirección permanente, así que probé con el atributo "follow_redirects=True":

 def login(client): return client.post("http://127.0.0.1:8080/login", data=dict( username="admin", password="taleinfo" ), follow_redirects=True)

Pero creo que es solo una forma de solucionar el problema, no creo que haya iniciado sesión después de eso.

aquí el error: E AssertionError: afirmar 308 == 200 E + donde 308 = <263 bytes [308 PERMANENT REDIRECT]>.status_code

No encuentro ningún problema similar. Gracias por tu ayuda.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Obtuve este mismo error como resultado de tener dos barras en mi camino. Era algo como:

 def test_my_annoying_failing_test(client): response = client.post('/api//my_path/to-somewhere') # notice the double slash # ...test continues here..

Cambiar esa barra doble a una sola barra lo arregló para mí:

 def test_my_annoying_failing_test(client): response = client.post('/api/my_path/to-somewhere') # ...test continues here..

Sin embargo, no estoy seguro de cuál es la causa raíz de ese problema.

over 4 years ago · Santiago Trujillo Report

0

Tuve el mismo problema, lo resolví agregando una barra oblicua /

prueba este código:

 def login(client): return client.post("http://127.0.0.1:8080/login/", data=dict( username="admin", password="secret" ))

como puede ver, agregue la barra inclinada en el inicio de sesión / así. Suena estúpido, lo sé, pero pruébalo y avísame.

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!