Skip to content

gh-120965: Skip test_zoneinfo.ExtensionBuiltTest if C extension is not available - #131104

Merged
StanFromIreland merged 9 commits into
python:mainfrom
StanFromIreland:fix-zone-tests
Oct 23, 2026
Merged

StanFromIreland merged 9 commits into
python:mainfrom
StanFromIreland:fix-zone-tests

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Mar 11, 2025 •

Copy link
Copy Markdown
Member

Preserves existing behavior for tests (c_module would just be the Python implementation) other than the one failing.

@StanFromIreland

Copy link
Copy Markdown
Member Author

Requesting @pganssle since is maintainer of zoneinfo (If I recall correctly)

@pganssle

Copy link
Copy Markdown
Member

I don't remember offhand, but I feel like the purpose of this test is to make sure nothing accidentally disables the zoneinfo C extension build, so disabling it if the C extension didn't get built seems counter-productive.

Is there a way to detect if it was intentionally not built? Something in sysconfig or something like that? Under what circumstances is it being deliberately disabled? If it is just pypy, do they have a preferred mechanism for communicating that a test like this can be skipped, preferably one that doesn't also make our tests more fragile?

@pganssle

Copy link
Copy Markdown
Member

Oh the docstring is maybe a little misleading, I think I remember this now. It's not testing that the C extension got built, it is making sure that the zoneinfo constructor isn't returning cached values from the wrong implementation. I think. I will have to look at this a bit later to convince myself 100% that it's not also the other thing, though.

@github-actions

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 22, 2026
@StanFromIreland

Copy link
Copy Markdown
Member Author

Oh the docstring is maybe a little misleading, I think I remember this now. It's not testing that the C extension got built, it is making sure that the zoneinfo constructor isn't returning cached values from the wrong implementation. I think. I will have to look at this a bit later to convince myself 100% that it's not also the other thing, though.

Yep, the test checks that c_zoneinfo and py_zoneinfo are different implementations. However, _zoneinfo can be missing if Python is built with _zoneinfo disabled (e.g., in Modules/Setup.local), or in other implementations like PyPy, which currently has to patch the test:

https://github.com/pypy/pypy/blob/ddbc5c1cbe7536b02f4fde697e7fab700b1fe0c5/lib-python/3/test/test_zoneinfo/test_zoneinfo.py#L1918-L1919

In those cases there is only one implementation so zoneinfo falls back to the pure-Python class, so there is no second implementation to mix up and nothing for this test to guard. The rest of the suite still runs against the Python class, so no coverage is lost.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Oct 8, 2026
@StanFromIreland
StanFromIreland merged commit 897671b into python:main Oct 23, 2026
52 checks passed
@StanFromIreland
StanFromIreland deleted the fix-zone-tests branch October 23, 2026 19:11
@StanFromIreland StanFromIreland added awaiting merge needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 23, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 23, 2026

Copy link
Copy Markdown

GH-160469 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 23, 2026
@bedevere-app

bedevere-app Bot commented Oct 23, 2026

Copy link
Copy Markdown

GH-160470 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 23, 2026
StanFromIreland added a commit that referenced this pull request Oct 23, 2026
…ion is not available (GH-131104) (#160469)

(cherry picked from commit 897671b)

Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
StanFromIreland added a commit that referenced this pull request Oct 23, 2026
…ion is not available (GH-131104) (#160470)

(cherry picked from commit 897671b)

Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants