Issue 22858: unittest.init:main shadows unittest.main (original) (raw)

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:10 admin set github: 67047
2021-12-12 00:26:56 iritkatriel set versions: + Python 3.11, - Python 3.5
2020-03-18 18:02:45 brett.cannon set nosy: - brett.cannon
2015-07-15 17:55:51 brett.cannon set messages: +
2015-07-15 17:55:35 brett.cannon set messages: +
2015-07-15 02:33:03 rbcollins set messages: +
2015-07-14 18:56:32 brett.cannon set nosy: + brett.cannonmessages: +
2015-07-14 01:04:14 rbcollins set messages: +
2015-07-14 01:03:46 rbcollins link issue24629 superseder
2014-11-20 17:00:56 michael.foord set messages: +
2014-11-14 21:21:45 terry.reedy set nosy: + ezio.melotti, michael.foord
2014-11-13 22:51:53 pitrou set nosy: + pitroumessages: +
2014-11-13 15:11:57 r.david.murray set nosy: + r.david.murraymessages: +
2014-11-13 10:23:36 rbcollins set type: behaviorcomponents: + Library (Lib)versions: + Python 3.5
2014-11-13 10:23:24 rbcollins create