GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-107862: Add property tests for strftime/strptime by pganssle · Pull Request #124550 · python/cpython

Conversation

@pganssle

@pganssle pganssle commented Sep 25, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This adds a new test for strptime / strftime that 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:

  • Add stubs to make sure this works without hypothesiis
  • Configure this the same way test_zoneinfo_property is configured so that it is run separately against the C and Python implementations.
  • Issue: [Meta] Research: what can we test with Hypothesis? #107862

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Sep 25, 2024
@pganssle
pganssle force-pushed the strftime_hypothesis branch from 9140d68 to bc0286c Compare September 25, 2024 22:11
@StanFromIreland StanFromIreland changed the title gh-NNNNNN: Add property tests for strftime/strptime gh-107862: Add property tests for strftime/strptime Sep 16, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Sep 16, 2025
[Meta] Research: what can we test with Hypothesis? #107862
Open
@StanFromIreland

StanFromIreland commented Sep 16, 2025

Copy link
Copy Markdown
Member

Attached Hypothesis meta issue #107862

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland StanFromIreland added the skip news label Sep 16, 2025
@StanFromIreland StanFromIreland mentioned this pull request Mar 18, 2026
Improve fuzz coverage python/library-fuzzers#8
Closed
@github-actions

github-actions Bot commented Apr 18, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 18, 2026
@tonghuaroot tonghuaroot mentioned this pull request Jun 25, 2026
datetime.fromisoformat() (C) drops the sub-second part of a UTC offset, breaking round-trips #152079
Closed
pganssle added 13 commits September 26, 2026 15:52
@pganssle
Add property tests for strftime/strptime
9893d09
@pganssle
Run datetime property examples without Hypothesis
7e98780
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.
@pganssle
Run datetime property tests against both implementations
4905a37
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.
@pganssle
fixup! Add property tests for strftime/strptime
ad213ec
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.
@pganssle
Add strptime calendar representation property tests
f3e4833
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.
@pganssle
Add strptime fraction and UTC offset property tests
9ea08b8
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.
@pganssle
Add strptime invalid-field property tests
9fe9f3c
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.
@pganssle
Add strptime name and literal property tests
ec83165
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.
@pganssle
Add strptime public entry point property tests
81c0aca
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.
@pganssle
Add expected failure for strptime rollover metadata
a85c9c7
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.
@pganssle
Add expected failure for repeated strptime directive errors
22ab46e
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.
@pganssle
Add strptime locale cache property tests
b38cd94
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.
@pganssle
Add strptime redundant directive ordering property tests
b43a3f5
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
pganssle force-pushed the strftime_hypothesis branch from bc0286c to b43a3f5 Compare September 26, 2026 22:13
@pganssle
fixup! Add expected failure for strptime rollover metadata
609ed13
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Oct 1, 2026
@StanFromIreland StanFromIreland mentioned this pull request Nov 9, 2026
OSS-Fuzz: Add new fuzzer/dict/corpus/scripts targets datetime processing python/library-fuzzers#63
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pganssle @StanFromIreland
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.