Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Getting 'Not Found' across all routes

Aperta
#190 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
flask, python
Ambito
testing

Direzione di ricerca

Esegui pytest src/tests/system/guest/test_login.py dal branch collegato tests/login_example, quindi esamina i fixture app, live_server e il driver Selenium mostrati nella issue. Confronta le route registrate in app.url_map con gli URL richiesti dal test; il lavoro è completato quando la route di login e il test non restituiscono più 404.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Describe the bug
Hello, I'm trying to run pytest-flask's live server in conjunction with selenium, but every one of my registered routes return a 404 status.
Both my app fixture and the live_server's app are the same (app == live_server.appreturns True, but I haven't checked out if they're the exact same object), and both app objects return the expected routes when calling app.url_map

It not only happens in testing: running the suite via a debugger and stopping the execution just before it fails, and visiting the app's routes in another tab or browser results in the same 404 status responses.

To Reproduce
I have the project open and available in github here, in the tests/login_example branch. Just start a virtual environment, install the requirements and run the following test:

pytest src/tests/system/guest/test_login.py

Expected behavior
The test passes.

Screenshots
Checking url_map in the debugger:
Screenshot from 2024-03-29 12-02-06

Firefox showing the error:

Screenshot from 2024-03-29 12-02-26

Environment (please complete the following information):

  • OS: ArchLinux with the Linux 6.8.2 kernel
  • Python Version: 3.11.8
  • pytest-flask version: 1.3.0

Additional context
The test proper:

@pytest.mark.usefixtures('live_server')
class TestLogin(TestSystemBase):
    def test_correct_login(db, driver, live_server):
        driver.get(f"http://localhost:8888{url_for('sessions_controller.new')}")
        assert 'Login' in driver.page_source

My app fixture:

@pytest.fixture(scope='session')
def app():
    app = Flask(__name__)
    app.config['TESTING'] = True
    initializer.init_app(app)
    app.config['SECRET_KEY'] = secrets.token_hex(32)

    with app.app_context():
        yield app

    clear_data(app)

My selenium driver fixture:

@pytest.fixture
def driver():
    options = webdriver.FirefoxOptions()
    #options.add_argument('-headless')
    driver = webdriver.Firefox(options=options)

    yield driver

    driver.close()
Lingua principale
Python
Stelle
499
Fork
93
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pytest-flask

Tutte le issue di pytest-dev/pytest-flask

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.