toml-test datetime cases use tomlkit's own parse_rfc3339 as the expected value, so they cannot detect datetime parsing bugs
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- testing-qa
調査の方向性
tests/test_toml_tests.py と parse_rfc3339 の期待値から始め、次に test_parse_rfc3339_datetime を含む 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
- スター
- 850
- フォーク
- 163
- 平均マージ
- 13分
- マージ済み PR(30日)
- 2
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-poetry/tomlkit のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python-poetry/tomlkit#546 · コメント 2 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
python-poetry/tomlkit#580 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
python-poetry/tomlkit#577 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
python-poetry/tomlkit#574 · コメント 5 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
python-poetry/tomlkit#571 ·
python-poetry/tomlkit の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
stephrobert/dsoxlab#238 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
sublimehq/package_control#1780 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nwg-piotr/nwg-displays#145 ·