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.

classification
Title: Clarify Test Coverage for the String Module (test_pep292 is not easily discoverable)
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, erinspace, gregory.p.smith, martin.panter, python-dev, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-06-02 17:54 by erinspace, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
stringtests.patch erinspace, 2016-06-02 17:54 review
stringtests.patch erinspace, 2016-06-02 19:42 review
Messages (25)
msg266902 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2016-06-02 18:28
Can you sign the Python contributor form  - https://www.python.org/psf/contrib/contrib-form/?  (If you already have, just say so.)
msg266905 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-02 18:33
string.Template is tested in Lib/test/test_pep292.py.
msg266906 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2016-06-02 18:36
Thanks Serhiy.  Given that, I suggest checking if the new tests this adds are already covered in test_pep292.py or not to decide if we should move forward with this patch or not.
msg266915 - (view) Author: Erin Braswell (erinspace) * Date: 2016-06-02 18:59
Just checked! Apologies for this totally unnecessary patch, didn't know to look elsewhere but now I absolutely do  -- looks like all the tests are there and more. Thank you!
msg266917 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2016-06-02 19:02
It probably makes sense to move test_pep292.py tests into test_string.py. Test files named after peps are not very helpful.
msg266920 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-02 19:05
Or at least add a reference in test_string.py.
msg266921 - (view) Author: Erin Braswell (erinspace) * Date: 2016-06-02 19:05
Oh! I can do that, and resubmit the patch! Good suggestion. Thank you again.
msg266930 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-06-02 19:25
Reopening and retitling.
msg266933 - (view) Author: Erin Braswell (erinspace) * Date: 2016-06-02 19:42
Here is an updated patch adding all the tests from test_pep292.py into test_string.py. After this happens test_pep292.py can be removed!
msg266935 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-02 19:50
This is not so easy. After adding all the tests from test_pep292.py into test_string.py and removing test_pep292.py we will lost all the history of test_pep292.py. Merging two files in Mercurial is not easy. I already did this and can do again if it is worth.
msg266938 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2016-06-02 19:52
I'm not too concerned about that. git can handle it well, which we will
have soon.

On Thu, Jun 2, 2016, at 12:50, Serhiy Storchaka wrote:
> 
> Serhiy Storchaka added the comment:
> 
> This is not so easy. After adding all the tests from test_pep292.py into
> test_string.py and removing test_pep292.py we will lost all the history
> of test_pep292.py. Merging two files in Mercurial is not easy. I already
> did this and can do again if it is worth.
> 
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue27185>
> _______________________________________
msg266944 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-06-02 20:54
Benjamin: meaning we should wait for git to merge it, or git will automatically handle the history after conversion?
msg266946 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2016-06-02 21:02
We should be able to commit it now. git blame can usually figure out
this stuff post facto.

On Thu, Jun 2, 2016, at 13:54, R. David Murray wrote:
> 
> R. David Murray added the comment:
> 
> Benjamin: meaning we should wait for git to merge it, or git will
> automatically handle the history after conversion?
> 
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue27185>
> _______________________________________
msg266967 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-06-02 22:03
All right, I'll go ahead and commit it, then.
msg266990 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-02 23:39
New changeset 89abefdebf4d by R David Murray in branch '3.5':
#27185: move test_pep292 into test_string.
https://hg.python.org/cpython/rev/89abefdebf4d

New changeset c2d3d8c3e0bf by R David Murray in branch 'default':
Merge: #27185: move test_pep292 into test_string.
https://hg.python.org/cpython/rev/c2d3d8c3e0bf
msg266991 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-06-02 23:41
Thanks, Erin.
msg266994 - (view) Author: Erin Braswell (erinspace) * Date: 2016-06-02 23:48
Hooray thank you everyone!
msg267018 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-06-03 01:28
FWIW I doubt Git is any better at this than Mercurial: <https://github.com/python/cpython/blame/master/Lib/test/test_string.py#L190>

Git can automatically pick up file renames and copies when analysing the history, but has no special metadata for this. I understand Mercurial is the opposite (has metadata, but at least by default does not pick up copies and renames from the history). Perhaps that is what Benjamin was thinking of. I understand Git will only pick up movements of the majority of a file, not parts of files (unless something has changed recently).

Perhaps Serhiy can clarify, but I imagine he was proposing something like this (which I have not tested):

A. Start at revision A
B. Remove test_string and rename test_pep292 in its place, giving revision B
C. Merge revisions A and B, and manually merge the contents of the two test_string versions, giving the final revision
msg267036 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-03 04:56
This is even more complex, since you can't merge a revision with its parent.

A. Start at revision A.
B. Rename test_string to test_string_merged, giving revision B.
A. Update back to revision A.
C. Rename test_pep292 to test_string_merged, giving revision C.
D. Merge revisions B and C, and manually merge the contents of the two test_string_merged versions, giving revision D.
E. Rename test_string_merged to test_string, giving the final revision.
msg267043 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2016-06-03 05:31
On Thu, Jun 2, 2016, at 18:28, Martin Panter wrote:
> 
> Martin Panter added the comment:
> 
> FWIW I doubt Git is any better at this than Mercurial:
> <https://github.com/python/cpython/blame/master/Lib/test/test_string.py#L190>
> 
> Git can automatically pick up file renames and copies when analysing the
> history, but has no special metadata for this. I understand Mercurial is
> the opposite (has metadata, but at least by default does not pick up
> copies and renames from the history). Perhaps that is what Benjamin was
> thinking of. I understand Git will only pick up movements of the majority
> of a file, not parts of files (unless something has changed recently).

git blame -C works quite well in my experience for detecting moved lines
of code.

In general, I think we shouldn't be afraid to reorganize code for fear
of breaking "VCS" history. The tools will catch up. (I think they
largely have already.) At worst, one must manually "follow" the move of
some code through history.
msg267058 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-03 06:39
New changeset 27f5eb630499 by Serhiy Storchaka in branch '2.7':
Issue #27185: Rename test_string.py to test_string_merged.py.
https://hg.python.org/cpython/rev/27f5eb630499

New changeset 8218b1309178 by Serhiy Storchaka in branch '2.7':
Issue #27185: Rename test_pep292.py to test_string_merged.py.
https://hg.python.org/cpython/rev/8218b1309178

New changeset 7dac80e0dd5e by Serhiy Storchaka in branch '2.7':
Issue #27185: Merge test_pep292.py into test_string_merged.py.
https://hg.python.org/cpython/rev/7dac80e0dd5e

New changeset e2e309fb2b1e by Serhiy Storchaka in branch '2.7':
Issue #27185: Rename test_string_merged.py back to test_string.py.
https://hg.python.org/cpython/rev/e2e309fb2b1e
msg267060 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-03 06:47
Merged test_pep292.py into test_string.py with preserving the history in 2.7.

This required following steps:

hg mv Lib/test/test_string.py Lib/test/test_string_merged.py
hg commit
hg update -C -r -2
hg mv Lib/test/test_pep292.py Lib/test/test_string_merged.py
hg commit
hg update -C -r -2
hg merge
# Manually merge the content of former test_string.py and test_pep292.py.
hg commit
hg mv Lib/test/test_string_merged.py Lib/test/test_string.py
hg commit
hg push

We now should restore deleted test_pep292.py (is it possible with the history?) and repeat above steps in 3.x.
msg267071 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-06-03 07:23
IMO I wouldn’t bother. David has already done the change a different way, which is simpler to understand commit-by-commit, even if it messes with the Mercurial annotate history.

FWIW I guess you could do a similar merge with an old version to restore the deleted file though.
msg267073 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-03 07:49
New changeset 70e19b014d2f by Serhiy Storchaka in branch '3.5':
Issue #27185: Rename test_string.py to test_string_merged.py.
https://hg.python.org/cpython/rev/70e19b014d2f

New changeset 0da07e73451d by Serhiy Storchaka in branch '3.5':
Issue #27185: Rename test_pep292.py to test_string_merged.py.
https://hg.python.org/cpython/rev/0da07e73451d

New changeset 14a036c696e8 by Serhiy Storchaka in branch '3.5':
Issue #27185: Merge test_pep292.py into test_string_merged.py.
https://hg.python.org/cpython/rev/14a036c696e8

New changeset 36f5229e45a6 by Serhiy Storchaka in branch '3.5':
Issue #27185: Rename test_string_merged.py back to test_string.py.
https://hg.python.org/cpython/rev/36f5229e45a6
msg267075 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-03 07:52
Now the history is restored.
History
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71372
2016-06-03 07:52:04serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg267075

stage: resolved
2016-06-03 07:49:08python-devsetmessages: + msg267073
2016-06-03 07:23:44martin.pantersetmessages: + msg267071
versions: + Python 2.7
2016-06-03 06:47:52serhiy.storchakasetmessages: + msg267060
2016-06-03 06:39:21python-devsetmessages: + msg267058
2016-06-03 05:31:42benjamin.petersonsetmessages: + msg267043
2016-06-03 04:56:48serhiy.storchakasetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg267036

stage: resolved -> (no value)
2016-06-03 01:28:12martin.pantersetnosy: + martin.panter
messages: + msg267018
2016-06-02 23:48:21erinspacesetmessages: + msg266994
2016-06-02 23:41:17r.david.murraysetstatus: open -> closed
versions: + Python 3.5, Python 3.6
messages: + msg266991

resolution: fixed
stage: resolved
2016-06-02 23:39:05python-devsetnosy: + python-dev
messages: + msg266990
2016-06-02 22:03:13r.david.murraysetmessages: + msg266967
2016-06-02 21:02:27benjamin.petersonsetmessages: + msg266946
2016-06-02 20:54:55r.david.murraysetmessages: + msg266944
2016-06-02 19:52:46benjamin.petersonsetmessages: + msg266938
2016-06-02 19:50:20serhiy.storchakasetmessages: + msg266935
2016-06-02 19:42:32erinspacesetfiles: + stringtests.patch

messages: + msg266933
2016-06-02 19:25:40r.david.murraysetstatus: closed -> open
title: Increase Test Coverage for the String Module -> Clarify Test Coverage for the String Module (test_pep292 is not easily discoverable)
nosy: + r.david.murray

messages: + msg266930

resolution: duplicate -> (no value)
2016-06-02 19:05:51erinspacesetmessages: + msg266921
2016-06-02 19:05:50serhiy.storchakasetmessages: + msg266920
2016-06-02 19:02:08benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg266917
2016-06-02 18:59:38erinspacesetstatus: open -> closed
resolution: duplicate
messages: + msg266915
2016-06-02 18:36:06gregory.p.smithsetmessages: + msg266906
2016-06-02 18:33:41serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg266905
2016-06-02 18:28:25gregory.p.smithsetnosy: + gregory.p.smith
messages: + msg266902
2016-06-02 17:54:58erinspacecreate