toml-test datetime cases use tomlkit's own parse_rfc3339 as the expected value, so they cannot detect datetime parsing bugs
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu với tests/test_toml_tests.py và các kỳ vọng của parse_rfc3339, sau đó chạy các bài kiểm thử datetime, bao gồm test_parse_rfc3339_datetime. Làm cho các kỳ vọng datetime độc lập với parser và bổ sung coverage cho offset +05:30; nếu xử lý issue liên quan đến helper, hãy kiểm tra tests/util.py::elementary_test và các trường hợp test_*_unwrap, với các assertion về giá trị là tiêu chí hoàn thành.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 850
- Fork
- 163
- Merge trung bình
- 13 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-poetry/tomlkit
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
python-poetry/tomlkit#546 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
python-poetry/tomlkit#580 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
python-poetry/tomlkit#577 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Looking for a co-maintainerĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
python-poetry/tomlkit#574 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
python-poetry/tomlkit#571 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của python-poetry/tomlkit
Issue tương tự
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
kristofdegrave/homeassistant-smart-charging#1413 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
nasa/earthdata-varinfo#113 ·
-
curriculum documentation quality
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
githubnext/gh-aw-workshop#3849 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày