Conversation
pganssle
force-pushed
the
strftime_hypothesis
branch
from
September 25, 2024 22:11
9140d68 to
bc0286c
Compare
Member
|
Attached Hypothesis meta issue #107862 |
|
This PR is stale because it has been open for 30 days with no activity. |
Add the missing timezones strategy stub and an explicit example so the test runs without Hypothesis installed. Use the C locale for the example to keep the composite format independent of the ambient locale.
Add a separate pure-Python test class using the same properties as the C implementation. Give its strptime module matching Python timezone classes and restore the module cache when the tests finish.
Correct the round-trip preconditions and preserve the minimized failures as explicit examples. Generate delimited fields, account for ignored week numbers and two-digit years, and keep locale composites in the C locale. Check small years and ambiguous fields against independent expected values.
Construct numeric, ordinal, ISO-week and calendar-week inputs without strftime, and compare parsed fields against date arithmetic. Keep leap days, year boundaries and the two-digit-year pivot as explicit examples.
Check fractional precision and signed offset components independently of datetime equality. Cover colon and compact spellings, Z, naive inputs, negative zero and offsets immediately inside the 24-hour boundary.
Mutate otherwise valid dates into impossible calendar dates, out-of-range clock fields and offsets, malformed fractions and incomplete ISO dates. Check ValueError without treating permissive but valid spellings as errors.
Use independent C-locale name tables and exercise case variants, 12-hour clock boundaries and Unicode whitespace. Keep NUL, surrogate, percent and regex punctuation literals in the parser domain even where libc strftime cannot round-trip them.
Compare date, time, datetime and struct_time results against independently constructed fields. Cover partial-input defaults, discarded components, ISO and ordinal dates, and agreeing redundant directives.
Week 53 and ordinal day 366 can normalize into the following year while tm_yday remains relative to the input year. Preserve the independently calculated date and day-of-year assertions as an expected failure until this inconsistency is resolved.
Conflicting repeated years should raise ValueError, but compiling the format leaks re.PatternError for the duplicate named group. Keep this failure separate from the passing mixed-directive property.
Parse localized names while switching from C to an available non-C locale and back. Build numeric fields independently, including years below 1000, and restore the caller locale after the test.
Permute agreeing date, clock and offset representations and compare the result with independently known fields. Cover calendar versus ISO years, 12-hour versus 24-hour clocks and both numeric offset directives.
pganssle
force-pushed
the
strftime_hypothesis
branch
from
September 26, 2026 22:13
bc0286c to
b43a3f5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a new test for
strptime/strftimethat uses hypothesis to ensure that some inverse relationships hold. While creating it I found several bugs: #124531, #124529 and #124549.I am hoping this could be useful with #120752
To Do:
test_zoneinfo_propertyis configured so that it is run separately against the C and Python implementations.