Skip to content

gh-66335: Add tests for imaplib command methods#152872

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:imaplib-test-coverage
Jul 2, 2026
Merged

gh-66335: Add tests for imaplib command methods#152872
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:imaplib-test-coverage

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 2, 2026

Copy link
Copy Markdown
Member

Add command-level tests for essentially every imaplib.IMAP4 method, using request/response samples from RFC 3501 and the relevant extension RFCs.

Each test drives a real client against an in-process SimpleIMAPHandler, asserts the exact bytes the server received (via a new splitargs tokenizer that keeps quoted strings and nested parenthesized lists whole), and checks the parsed return value, including the untagged responses for the list-returning commands.

Covered: select (incl. readonly=TrueEXAMINE), create, delete, rename, subscribe, unsubscribe, list, lsub, status, copy, fetch, store, search, sort, thread (and their UID variants), expunge, close, check, noop, namespace, capability, recent, response, partial, proxyauth, xatom, enable, and the ACL/QUOTA/ANNOTATION commands.

The assertions reflect current behavior only; the argument-quoting fix in #152703 will build on these tests, adjusting the expected wire forms.

append (literal handling) is covered by #152775, and move() by gh-77508; starttls needs a TLS-upgrade test server and is left for separate work.

Add coverage tests for the IMAP4 command methods and their UID variants
(SELECT, CREATE, COPY, STORE, FETCH, SEARCH, SORT, THREAD, DELETE,
RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, the ACL and quota
commands, ANNOTATION, PROXYAUTH and ENABLE), plus test helpers
(splitargs, parse_sequence_set, make_simple_handler) and per-command
argument capture in the test server.

The tests assert the current wire behavior; a follow-up for pythongh-40038
updates the expected values once argument quoting is restored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka requested a review from a team as a code owner July 2, 2026 09:45
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Jul 2, 2026
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 2, 2026
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 2, 2026 09:52
@serhiy-storchaka serhiy-storchaka merged commit a50b089 into python:main Jul 2, 2026
60 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 2, 2026
@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152874 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 Jul 2, 2026
@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152875 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 2, 2026
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…H-152875)

Add coverage tests for the IMAP4 command methods and their UID variants
(SELECT, CREATE, COPY, STORE, FETCH, SEARCH, SORT, THREAD, DELETE,
RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, the ACL and quota
commands, ANNOTATION, PROXYAUTH and ENABLE), plus test helpers
(splitargs, parse_sequence_set, make_simple_handler) and per-command
argument capture in the test server.
(cherry picked from commit a50b089)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…H-152873)

Add coverage tests for the IMAP4 command methods and their UID variants
(SELECT, CREATE, COPY, STORE, FETCH, SEARCH, SORT, THREAD, DELETE,
RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, the ACL and quota
commands, ANNOTATION, PROXYAUTH and ENABLE), plus test helpers
(splitargs, parse_sequence_set, make_simple_handler) and per-command
argument capture in the test server.
(cherry picked from commit a50b089)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…H-152874)

Add coverage tests for the IMAP4 command methods and their UID variants
(SELECT, CREATE, COPY, STORE, FETCH, SEARCH, SORT, THREAD, DELETE,
RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, the ACL and quota
commands, ANNOTATION, PROXYAUTH and ENABLE), plus test helpers
(splitargs, parse_sequence_set, make_simple_handler) and per-command
argument capture in the test server.
(cherry picked from commit a50b089)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka deleted the imaplib-test-coverage branch July 2, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant