classification
Title: Have test___all__ check for duplicates
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: 11081 Superseder:
Assigned To: ezio.melotti Nosy List: SilentGhost, belopolsky, ezio.melotti, pitrou, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2011-01-31 15:55 by r.david.murray, last changed 2013-05-01 11:59 by ezio.melotti. This issue is now closed.

Files
File name Uploaded Description Edit
check_all_for_duplicates.patch r.david.murray, 2011-01-31 15:55 review
issue11078.diff ezio.melotti, 2013-04-19 02:27 Updated patch -- the changes to the __all__s should not be committed. review
Messages (8)
msg127608 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-01-31 15:55
Inspired by what happened in issue 8973, I offer the attached patch for test__all__ to have it check the __all__ list for duplicates.  Interestingly, the first failure is not in struct, but in os.  Obviously the patch can't be applied until the test succeeds, so I'll be coming back to this later.  Figured I'd post the test patch in case anyone else wants to play with fixing things before I get to it.
msg127613 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-01-31 16:27
+1.  This is a fairly common mistake.  Usually benign, but as issue 8973 shows, may highlight a visible error.
msg127621 - (view) Author: SilentGhost (SilentGhost) * Date: 2011-01-31 17:00
At the moment test fails only for os module on windows. 

These are the offending names: putenv, spawnv, spawnve

The reason is that __all__ is extended with ntpath.__all__ and then again in the body of os.py (I'm not entirely sure how this could be fixed elegantly).
msg127622 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-01-31 17:09
Well, the test stops testing after the first failure.  Perhaps another enhancement request would be to make test__all__ a parameterized test so that it tests all modules even if one or more fail.

On linux, the dups are putenv and unsetenv.  And yes, deeper investigation of why os.py is adding them is required to fix this :)
msg127623 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-01-31 17:15
On Mon, Jan 31, 2011 at 12:09 PM, R. David Murray
<report@bugs.python.org> wrote:
..
> On linux, the dups are putenv and unsetenv.  And yes, deeper investigation of why
> os.py is adding them is required to fix this :)

Too bad __all__ cannot be specified as a set.
msg127624 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-01-31 17:18
Well, checking if the token is there before adding it would certainly be a fix, but I think it would be worth understanding why it gets added if it is already there, because instead perhaps it is possible to simply remove the adding code from os.py.  Removing code is nice.
msg187331 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-04-19 02:27
Attached an updated patch that also uses subtests to keep running all tests even in case of failure.
The patch also intentionally breaks a few __all__ to show how it works -- these changes should clearly be removed once the patch gets committed.
msg188211 - (view) Author: Roundup Robot (python-dev) Date: 2013-05-01 11:58
New changeset 3f1bcfbed022 by Ezio Melotti in branch 'default':
#11078: test___all__ now checks for duplicates in __all__.  Initial patch by R. David Murray.
http://hg.python.org/cpython/rev/3f1bcfbed022
History
Date User Action Args
2013-05-01 11:59:15ezio.melottisetstatus: open -> closed
assignee: ezio.melotti
resolution: fixed
stage: patch review -> resolved
2013-05-01 11:58:24python-devsetnosy: + python-dev
messages: + msg188211
2013-04-19 02:27:30ezio.melottisetfiles: + issue11078.diff
versions: + Python 3.4, - Python 3.3
nosy: + ezio.melotti

messages: + msg187331

stage: needs patch -> patch review
2011-01-31 17:35:17belopolskysetnosy: belopolsky, pitrou, r.david.murray, SilentGhost
dependencies: + from struct import * misses pack_into
2011-01-31 17:18:32r.david.murraysetnosy: belopolsky, pitrou, r.david.murray, SilentGhost
messages: + msg127624
2011-01-31 17:15:19belopolskysetnosy: belopolsky, pitrou, r.david.murray, SilentGhost
messages: + msg127623
2011-01-31 17:09:29r.david.murraysetnosy: belopolsky, pitrou, r.david.murray, SilentGhost
messages: + msg127622
2011-01-31 17:00:37SilentGhostsetnosy: belopolsky, pitrou, r.david.murray, SilentGhost
messages: + msg127621
2011-01-31 16:27:44belopolskysetnosy: + belopolsky
messages: + msg127613
2011-01-31 15:55:32r.david.murraycreate