gh-138621: Increase test coverage for csv.DictReader and csv.Sniffer#138622
Merged
gpshead merged 6 commits intopython:mainfrom Nov 12, 2025
Merged
gh-138621: Increase test coverage for csv.DictReader and csv.Sniffer#138622gpshead merged 6 commits intopython:mainfrom
gpshead merged 6 commits intopython:mainfrom
Conversation
Previously there were no tests for the DictReader fieldnames setter, the case where a StopIteration was encountered when trying to determine the fieldnames from the content or the case where Sniffer could not find a delimiter.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Contributor
Author
|
I had originally skipped adding a test for the "check > 20" line because i thought that might be an implementation detail we dont want to fix down, but after seeing this, i realized this is officially documented so i think it makes sense to add a test for it. This now gets us to |
picnixz
reviewed
Sep 8, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz
reviewed
Sep 8, 2025
Contributor
Author
|
I think the test failure is unrelated? |
Member
|
Yes, don't worry |
gpshead
approved these changes
Sep 14, 2025
|
Thanks @JanEricNitschke for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Nov 12, 2025
…iffer (pythonGH-138622) * Increase test coverage for csv.DictReader and csv.Sniffer Previously there were no tests for the DictReader fieldnames setter, the case where a StopIteration was encountered when trying to determine the fieldnames from the content or the case where Sniffer could not find a delimiter. * Revert whitespace change to comment * Add a test that csv.Sniffer.has_header checks up to 20 rows * Replace name and age with letter and offset Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Address review comment --------- (cherry picked from commit 0e88be6) Co-authored-by: Jan-Eric Nitschke <47750513+JanEricNitschke@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
|
GH-141436 is a backport of this pull request to the 3.14 branch. |
gpshead
added a commit
that referenced
this pull request
Nov 12, 2025
…niffer (GH-138622) (#141436) gh-138621: Increase test coverage for csv.DictReader and csv.Sniffer (GH-138622) * Increase test coverage for csv.DictReader and csv.Sniffer Previously there were no tests for the DictReader fieldnames setter, the case where a StopIteration was encountered when trying to determine the fieldnames from the content or the case where Sniffer could not find a delimiter. * Revert whitespace change to comment * Add a test that csv.Sniffer.has_header checks up to 20 rows * Replace name and age with letter and offset * Address review comment --------- (cherry picked from commit 0e88be6) Co-authored-by: Jan-Eric Nitschke <47750513+JanEricNitschke@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
StanFromIreland
pushed a commit
to StanFromIreland/cpython
that referenced
this pull request
Dec 6, 2025
…iffer (pythonGH-138622) * Increase test coverage for csv.DictReader and csv.Sniffer Previously there were no tests for the DictReader fieldnames setter, the case where a StopIteration was encountered when trying to determine the fieldnames from the content or the case where Sniffer could not find a delimiter. * Revert whitespace change to comment * Add a test that csv.Sniffer.has_header checks up to 20 rows * Replace name and age with letter and offset Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Address review comment --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
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.
Previously there were no tests for the DictReader fieldnames setter, the case where a StopIteration was encountered when trying to determine the fieldnames from the content or the case where Sniffer could not find a delimiter.
Previously:
After:
This is my first attempt at contributing to CPython. I read through the dev guide. The easy issues (at least the recent ones i checked) seem to all already be assigned to someone and so i want the Increase test coverage.
Currently just going through modules alphabetically to check where i can see some fairly easy targets for increasing coverage. If there are any larger or more important modules i would love to have a look at those too if you could point me to them before i get to them in alphabetical order.