This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: string.py increased test coverage
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ncoghlan Nosy List: Alicia.Arlen, barry, brian.curtin, eric.smith, georg.brandl, jerome.radix, ncoghlan, python-dev
Priority: normal Keywords: patch

Created on 2011-03-14 19:37 by Alicia.Arlen, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
string_test_coverage.diff Alicia.Arlen, 2011-03-14 19:37 review
test_vformat_assert.patch jerome.radix, 2011-03-17 00:05 review
Messages (7)
msg130880 - (view) Author: Alicia Arlen (Alicia.Arlen) * Date: 2011-03-14 19:37
Started from coverage.py results.  Only 6 groups of lines did not have coverage.  Since the Template class originated in PEP292, those tests were added in test_pep292.py.  All Formatter class tests were added in test_string.py.

_invalid test (Lines 89-90):
  This error does not naturally occur, so the regex for pattern was overloaded to create the scenario where the format fails on the first character.

_vformat test (line 174):
  Forced recursion_depth negative to raise the error.

convert_field (lines 226, 299):
  Sent in appropriate convversion requests.

get_field (lines 256-257, 259):
  Added fieldname variations to test getattr and getitem lookups.
msg130923 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-03-14 23:01
New changeset 10c56e7ceb72 by Nick Coghlan in branch 'default':
Close #11505: Improve string.py coverage
http://hg.python.org/cpython/rev/10c56e7ceb72
msg130993 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2011-03-15 16:34
After discussion, it's probably a good idea to back port this to Python 3.2.
msg131198 - (view) Author: Jérôme Radix (jerome.radix) Date: 2011-03-17 00:05
There seems to be a small problem with parameters when calling _vformat. Your test is OK because _vformat raises an exception before using those parameters.

See test_vformat_assert.patch for a correction proposal.
msg131256 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-03-17 14:42
Reopening to double check with Jerome's patch.
msg137350 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-31 09:40
New changeset f1a213d034af by Nick Coghlan in branch 'default':
Tidy up the additional string module tests added at the Pycon sprints (closes #11505)
http://hg.python.org/cpython/rev/f1a213d034af
msg137354 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-05-31 09:54
Some comments on the follow-up changes I just committed:

- It's an illustration of the fact that coverage data is only step 1 in improving tests.

- I added additional assertions regarding the error message contents to a couple of tests, and also verified that the formatting code correctly allowed AttributeError, KeyError and IndexError to escape to the calling code when using subfield lookup.

- I changed the names of several of the test methods to more accurately reflect what they were designed to test.

- I broke up the original string formatting tests into multiple test methods. This fit in better with the updated method names and helps with diagnosing any errors that do arise in the future, since the smaller test methods help localise any failures.

- complex white-box tests designed to exercise obscure error paths definitely benefit from comments explaining what they're trying to do, which is definitely the case for the new test in test_pep292 which required an appropriately crafted template pattern

- I adjusted some of the new test methods to follow the same naming conventions as similar tests that were already in the test cases

Still, thanks to Alicia for the original patch and Jerome for picking up on the error in the vformat recursion limit test. Even if the final code doesn't look much like the initial patch, the latest version of these changes likely wouldn't have happened without those contributions.
History
Date User Action Args
2022-04-11 14:57:14adminsetgithub: 55714
2011-05-31 09:55:19ncoghlansetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2011-05-31 09:54:33ncoghlansetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg137354

stage: resolved -> commit review
2011-05-31 09:40:24python-devsetstatus: open -> closed

resolution: fixed
messages: + msg137350
stage: commit review -> resolved
2011-03-17 14:42:59ncoghlansetstatus: closed -> open
nosy: barry, georg.brandl, ncoghlan, eric.smith, brian.curtin, jerome.radix, python-dev, Alicia.Arlen
messages: + msg131256

resolution: fixed -> (no value)
stage: resolved -> commit review
2011-03-17 00:05:59jerome.radixsetfiles: + test_vformat_assert.patch
nosy: + jerome.radix
messages: + msg131198

2011-03-15 16:34:02barrysetnosy: + barry
messages: + msg130993
2011-03-14 23:01:12python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg130923

resolution: fixed
stage: resolved
2011-03-14 21:29:59ncoghlansetassignee: ncoghlan

nosy: + ncoghlan
2011-03-14 19:54:53eric.smithsetnosy: + eric.smith
2011-03-14 19:37:39Alicia.Arlencreate