Код: Выделить всё
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
Код: Выделить всё
def login(client):
return client.post("http://127.0.0.1:8080/login", data=dict(
username="admin",
password="taleinfo"
), follow_redirects=True)
здесь ошибка:
E AssertionError: утверждения 308 == 200
E + где 308 = < 263 байта [308 PERMANENT REDIRECT]>.status_code
Подобной проблемы не обнаружил.
Спасибо за помощь.
Подробнее здесь: https://stackoverflow.com/questions/614 ... when-login
Мобильная версия