Title: Check calculated constants in
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, JoelLuellwitz, Lynne.Qu, benjamin.peterson, brian.curtin, chalmerlowe, python-dev, r.david.murray, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2011-04-03 19:52 by Lynne.Qu, last changed 2015-04-14 00:11 by r.david.murray. This issue is now closed.

File name Uploaded Description Edit
test_calculated_constants.diff Lynne.Qu, 2011-04-03 19:52
test_calculated_constants.diff JoelLuellwitz, 2011-04-03 20:32
issue11754_patch.txt chalmerlowe, 2015-04-13 20:29 hg diff of review
issue11754_patch_2.txt chalmerlowe, 2015-04-13 23:13 Revised patch file... review
Messages (11)
msg132874 - (view) Author: Lynne Qu (Lynne.Qu) Date: 2011-04-03 19:52
Changed test to check calculated constants in
msg132879 - (view) Author: Joel Luellwitz (JoelLuellwitz) Date: 2011-04-03 20:32
Make a slight change to diff file.
msg132981 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-04-04 22:12
Being rather circular, that doesn't seem to be a particularly useful test. (Not that the original is either.) It'd be more "correct" if you actually tested that hex numbers are contained within string.hexdigits, for example.
msg133347 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-04-08 22:36
I do not understand 'circular'. The change is from 'attribute exists' to 'attribute has correct value'. If any are changed, I would think all should be changed.
msg221738 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-27 21:27
I see very little value in implementing this change, thoughts?
msg221766 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-28 02:02
Three years later, I do understand 'circular'. Such cut-and-paste whitebox tests tend to simultaneously test too much -- the particular implementation(1) -- and too little -- the actual specification(2).

(1) The test would falsely fail if a string were reordered but still correct.
(2) The test would falsely pass is any of the existing strings were incorrect. Most of the strings have a specification other than the existing string and all can be tested in an order free manner. Hexdigits example:

import string
assert len(set(string.hexdigits)) == 22
for c in string.hexdigits:
    assert '0' <= c <= '9' or 'a' <= c <= 'f' or 'A' <= c <= 'F'

I would be willing to push such a patch. I would also be willing to close this now.
msg240734 - (view) Author: chalmer_lowe (chalmerlowe) * Date: 2015-04-13 20:29
Discussed with David Murray at PyCon Sprints 2015.
Considered the fact that to preserve backwards compatibility, it seems important that rather than
a) merely checking for the presence of each constant string (as the test does now) OR
b) checking for each desired character (regardless of order) as noted in msg221766

the tests should check for the exact strings that have historically been published in Python. Doing so seems to be the right path to ensure that:
a) the strings exist AND
b) the strings have not inadvertently changed.
msg240751 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-04-13 21:06
Added a review comment.
msg240803 - (view) Author: chalmer_lowe (chalmerlowe) * Date: 2015-04-13 23:13
Based on review comments, in order to reduce unnecessary redundancy in the tests:
- composed later strings from previously defined substrings, where it made sense to do so.
msg240812 - (view) Author: Roundup Robot (python-dev) Date: 2015-04-14 00:08
New changeset e1457e9f340f by R David Murray in branch 'default':
#11754: test contents of string module attributes.
msg240813 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-04-14 00:11
Thanks, Chalmer.  Hopefully Benjamin won't be too annoyed by these :)
Date User Action Args
2015-04-14 00:11:17r.david.murraysetstatus: open -> closed
versions: - Python 2.7, Python 3.4
messages: + msg240813

resolution: fixed
stage: needs patch -> resolved
2015-04-14 00:08:44python-devsetnosy: + python-dev
messages: + msg240812
2015-04-13 23:13:49chalmerlowesetfiles: + issue11754_patch_2.txt

messages: + msg240803
2015-04-13 21:06:10r.david.murraysetnosy: + r.david.murray
messages: + msg240751
2015-04-13 20:29:09chalmerlowesetfiles: + issue11754_patch.txt
nosy: + chalmerlowe
messages: + msg240734

2014-06-28 03:40:05terry.reedysettitle: Changed test to check calculated constants in -> Check calculated constants in
2014-06-28 02:02:51terry.reedysetkeywords: + easy
type: behavior -> enhancement
messages: + msg221766

stage: needs patch
2014-06-27 21:27:41BreamoreBoysetnosy: + BreamoreBoy

messages: + msg221738
versions: + Python 2.7, Python 3.4, Python 3.5, - Python 3.3
2011-04-08 22:36:16terry.reedysetnosy: + terry.reedy
messages: + msg133347
2011-04-04 22:12:14benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg132981
2011-04-04 16:12:23brian.curtinsetnosy: + brian.curtin
2011-04-03 20:32:23JoelLuellwitzsetfiles: + test_calculated_constants.diff
nosy: + JoelLuellwitz
messages: + msg132879

2011-04-03 19:52:26Lynne.Qucreate