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: unittest.__init__:main shadows unittest.main
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, michael.foord, pitrou, r.david.murray, rbcollins
Priority: normal Keywords:

Created on 2014-11-13 10:23 by rbcollins, last changed 2022-04-11 14:58 by admin.

Messages (9)
msg231101 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-11-13 10:23
This is just an ugly/hygiene thing. Since we've never advertised the submodules as the API, we should be able to fix this by moving main.py to e.g. __main__.py.
msg231119 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-11-13 15:11
I'm afraid that just because we don't advertise it doesn't mean it isn't used.  On the other hand, the split into submodules is relatively recent, so maybe we could get away with it without a deprecation cycle.  I'd like other developers opinions on that.
msg231139 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-11-13 22:51
Numba subclasses unittest.main in order to add custom CLI options.
I agree the current unittest scheme is horrible, just we should find a way that's backwards-compatible.
msg231440 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2014-11-20 17:00
One way would be to have an _main.py and have main.py "import *" (or equivalent) from it. We can't get rid of unittest.main being an alias for TestProgram - that's been around forever.
msg246706 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-07-14 01:04
See also  https://github.com/testing-cabal/mock/issues/250
msg246738 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-07-14 18:56
The modules seem to have existed since at least Python 3.2, so I think a proper DeprecationWarning is necessary for just one release.

The trick is going to be unittest.main since it seems code in the wild relies on it at least partially existing and Michael thinks it should stick around in some form or another. If the desire is there to limit the API for unittest.main compared to what it is now, either people have to go with stuff disappearing on users that get moved out to _main, or you have to do a somewhat evil import hack and turn unittest.main into an object with attributes which raise a DeprecationWarning for those objects you want to relocate and not for those you want to leave in place.
msg246751 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-07-15 02:33
So unittest.main, the symbol, needs to exist.

What currently references unittest.main, the module, today?

AFAICT its only accessible vis sys.modules['unittest.main'] because of the shadowing.
msg246771 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-07-15 17:55
Ah, I see my misunderstanding; when Antoine said "Numba subclasses unittest.main" I wasn't thinking and thought he meant something in unitest.main the module, not the unittest.main alias for unittest.main.TestProgram which is exposed as unitest.__init__.main (yeah, that name clash is nasty).

Then the unittest.main module can be treated like any other module in terms of deprecation and doesn't need any special-casing. Sorry about the mix-up on my end. So I say rename the modules to _*, add the deprecation to the old names in 3.6, and then remove the modules in 3.7.
msg246772 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-07-15 17:55
Or deprecate in 3.5 if Larry will let you.
History
Date User Action Args
2022-04-11 14:58:10adminsetgithub: 67047
2021-12-12 00:26:56iritkatrielsetversions: + Python 3.11, - Python 3.5
2020-03-18 18:02:45brett.cannonsetnosy: - brett.cannon
2015-07-15 17:55:51brett.cannonsetmessages: + msg246772
2015-07-15 17:55:35brett.cannonsetmessages: + msg246771
2015-07-15 02:33:03rbcollinssetmessages: + msg246751
2015-07-14 18:56:32brett.cannonsetnosy: + brett.cannon
messages: + msg246738
2015-07-14 01:04:14rbcollinssetmessages: + msg246706
2015-07-14 01:03:46rbcollinslinkissue24629 superseder
2014-11-20 17:00:56michael.foordsetmessages: + msg231440
2014-11-14 21:21:45terry.reedysetnosy: + ezio.melotti, michael.foord
2014-11-13 22:51:53pitrousetnosy: + pitrou
messages: + msg231139
2014-11-13 15:11:57r.david.murraysetnosy: + r.david.murray
messages: + msg231119
2014-11-13 10:23:36rbcollinssettype: behavior
components: + Library (Lib)
versions: + Python 3.5
2014-11-13 10:23:24rbcollinscreate