Skip to content

Conversation

@JanEricNitschke
Copy link
Contributor

@JanEricNitschke JanEricNitschke commented Sep 7, 2025

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:

Name         Stmts   Miss Branch BrPart  Cover   Missing
--------------------------------------------------------
Lib/csv.py     262     10     96      8    95%   107->109, 164-165, 171, 255, 305->307, 312->314, 316-317, 327, 431, 434->443, 474, 511
--------------------------------------------------

After:

Name         Stmts   Miss Branch BrPart  Cover   Missing
--------------------------------------------------------
Lib/csv.py     262      5     96      6    97%   107->109, 305->307, 312->314, 316-317, 327, 434->443, 474, 511
--------------------------------------------------------
TOTAL          262      5     96      6    97%


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.

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.
@python-cla-bot
Copy link

python-cla-bot bot commented Sep 7, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Sep 7, 2025

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 skip news label instead.

@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Sep 7, 2025
@JanEricNitschke
Copy link
Contributor Author

JanEricNitschke commented Sep 8, 2025

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

Name         Stmts   Miss Branch BrPart  Cover   Missing
--------------------------------------------------------
Lib/csv.py     262      4     96      5    97%   107->109, 305->307, 312->314, 316-317, 327, 434->443, 511
--------------------------------------------------------
TOTAL          262      4     96      5    97%


Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@JanEricNitschke
Copy link
Contributor Author

I think the test failure is unrelated?

==> Fetching make
==> Downloading https://ghcr.io/v2/homebrew/core/make/blobs/sha256:94377dc5a364da305c75fd7aa923a42897993de9edd1eb074428e13c3f2aaf93
curl: (56) The requested URL returned error: 502
Error: make: Failed to download resource "make"
Download failed: https://ghcr.io/v2/homebrew/core/make/blobs/sha256:94377dc5a364da305c75fd7aa923a42897993de9edd1eb074428e13c3f2aaf93

@picnixz
Copy link
Member

picnixz commented Sep 8, 2025

Yes, don't worry

@gpshead gpshead added the needs backport to 3.14 bugs and security fixes label Nov 12, 2025
@gpshead gpshead enabled auto-merge (squash) November 12, 2025 00:14
@gpshead gpshead merged commit 0e88be6 into python:main Nov 12, 2025
46 checks passed
@miss-islington-app
Copy link

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>
@bedevere-app
Copy link

bedevere-app bot commented Nov 12, 2025

GH-141436 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 Nov 12, 2025
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>
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.

5 participants