toml-test datetime cases use tomlkit's own parse_rfc3339 as the expected value, so they cannot detect datetime parsing bugs
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- testing-qa
调研方向
从 tests/test_toml_tests.py 和 parse_rfc3339 的预期开始,然后运行 datetime 测试,包括 test_parse_rfc3339_datetime。使 datetime 预期独立于 parser,并为 +05:30 偏移添加覆盖;如果处理相关的 helper issue,请检查 tests/util.py::elementary_test 和 test_*_unwrap 用例,并以值断言作为完成标准。
由索引模型根据 Issue 内容生成。
描述
While running a mutation-based check of the test suite at 4b38bec, one structural gap stood out and seemed worth reporting. Nothing here is a bug in tomlkit's code — every mutation below was a deliberate break, and the code as shipped is correct.
What was observed
tests/test_toml_tests.py builds the expected value for every datetime-typed case with tomlkit._utils.parse_rfc3339:
stypes = {
...
"datetime": parse_rfc3339,
"datetime-local": parse_rfc3339,
"date-local": parse_rfc3339,
"time-local": parse_rfc3339,
}
That is the function under test, so for those four types the parser and the expectation drift together. Breaking the negative-offset sign in parse_rfc3339 (if sign == "-": offset = -offset → never negating) produced:
| red | |
|---|---|
| toml-test compliance cases (680) | 0 |
| hand-written tests (378) | 3 (test_parse_rfc3339_datetime ×2, test_datetimes_behave_like_datetimes) |
By contrast, dropping the integer sign in the parser reddened 6 compliance cases and untranslated string escapes 7 — for int and str the corpus is an independent oracle. For datetimes it is not, and the entire guard is three hand-written tests.
Related, smaller: no input anywhere in tests/ (hand-written or corpus) carries a non-zero minute offset, so +05:30 being parsed as +05:00 (dropping minute_offset from the timedelta) survives the whole suite.
Possible fix
Build datetime expectations independently — datetime.fromisoformat accepts RFC 3339 on Python 3.11+ and the project already requires ≥3.9 with a compat shim, or a tiny hand-rolled regex as the toml-test JSON format is fixed — and add one +05:30-style case to test_parse_rfc3339_datetime.
Also noticed
tests/util.py::elementary_test asserts isinstance(v.unwrap(), unwrapped_type) only, so the nine test_*_unwrap tests detect a wrong type but not a wrong value: Bool.unwrap returning not bool(self) passes test_true_unwrap and test_false_unwrap. Passing the expected value to the helper would close that.
Full write-up with the mutation spec and per-test results, reproducible against 4b38bec: https://github.com/ArnauFerma/falsifiable-tests/blob/main/case-studies/tomlkit.md
Happy to send a PR for either if you'd take one.
- 主要语言
- Python
- 星标
- 859
- 派生
- 186
- 平均合并
- 3 天 2 小时
- 30 天内合并 PR
- 11
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-poetry/tomlkit 的其他 Issue
-
item() reorders keys (dict-valued before scalar) even with the default sort_keys=False可能已有人在做 @uttam12331 于 99 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
python-poetry/tomlkit#546 · 2 条评论 ·
维护者通常 1 天内回复
-
tomlkit 0.15.1 fails on out-of-order table header可能已有人在做 @0xrutabaga 于 5 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 45/100
python-poetry/tomlkit#632 ·
维护者通常 1 天内回复
-
`dumps(sort_keys=True)` only sorts the top level of a parsed document (nested tables / inline tables / AoT keep original order)可能已有人在做 @Sreekant13 于 13 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 35/100
python-poetry/tomlkit#614 · 2 条评论 ·
维护者通常 1 天内回复
-
`Array.add_line()` doesn't serialize as documented (or expected) and can even produce syntactically invalid TOML可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 52/100
python-poetry/tomlkit#580 · 1 条评论 ·
维护者通常 1 天内回复
-
unwrap raises KeyAlreadyPresent for an out-of-order AoT element extension可能已有人在做 @davidpavlovschi 于 76 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 72/100
python-poetry/tomlkit#577 ·
维护者通常 1 天内回复
查看 python-poetry/tomlkit 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
huggingface/smolagents#2976 ·
维护者通常 1 天内回复
-
bug Triage-Needed
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
FuRongJun-1999/dsh-memory#170 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
pgvector/pgvector-python#163 ·
-
难度 1/5 1 小时以内 新手友好度 82/100
521xueweihan/HelloGitHub#3940 ·