homepage

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

AltStyle によって変換されたページ (->オリジナル) /