Getting 'Not Found' across all routes
还没有人认领这个 Issue。
评估
调研方向
从关联的 tests/login_example 分支运行 pytest src/tests/system/guest/test_login.py,然后检查 issue 中显示的 app、live_server 和 Selenium driver fixture。将 app.url_map 中注册的路由与测试请求的 URL 进行比较;当登录路由和测试不再返回 404 时即表示完成。
由索引模型根据 Issue 内容生成。
描述
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:
Firefox showing the error:
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()
- 主要语言
- Python
- 星标
- 499
- 派生
- 94
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytest-dev/pytest-flask 的其他 Issue
-
live_server fails with Python 3.14's forkserver default on Linux可能已有人在做 @vitlav 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
pytest-dev/pytest-flask#206 ·
-
bug
难度 4/5 3-5 天 新手友好度 35/100
pytest-dev/pytest-flask#187 · 7 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 45/100
pytest-dev/pytest-flask#175 · 3 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
pytest-dev/pytest-flask#163 · 1 条评论 · 1 个 reaction ·
-
feature request
难度 4/5 3-5 天 新手友好度 45/100
pytest-dev/pytest-flask#153 · 1 条评论 ·
查看 pytest-dev/pytest-flask 的全部 Issue
相似的 Issue
-
request-theme
难度 1/5 1 小时以内 新手友好度 66/100
LizardByte/ThemerrDB#9575 ·
维护者通常 1 天内回复
-
author-page correction
难度 2/5 1-3 小时 新手友好度 62/100
acl-org/acl-anthology#10599 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
zilliztech/memsearch#818 ·
维护者通常 1 天内回复
-
[FAQ] Commit ID for Projects可能已有人在做 @github-actions 今天认领。 未关闭faq-proposal
难度 1/5 1 小时以内 新手友好度 84/100
DataTalksClub/faq#503 · 1 条评论 ·
维护者通常 2 天内回复
-
README.zh-CN/ja/es still hard-code 501 test counts after README.md went count-free可能已有人在做 @Aaqibhafeezkhan 今天认领。 未关闭beginner documentation good first issue
难度 2/5 1-3 小时 新手友好度 75/100
BistaDinesh03/critique#164 · 1 条评论 ·
维护者通常 1 天内回复