[Python-ideas] Proposal for special name and qualname symbols
Steven D'Aprano
steve at pearwood.info
Wed Jun 8 23:43:23 EDT 2016
On Thu, Jun 09, 2016 at 03:29:07AM +0100, MRAB wrote:
> A workaround is to use a comment:
>
> #@public
> SEVEN = 7
>
> and a script that parses the file and updates the __all__.
Ooooh! I like that! Except that instead of a scripting updating __all__,
it's a unit test that fails.
I don't know if this should go into unittest or test.support.
https://docs.python.org/3/library/test.html#module-test.support
Off the top of my head, something like:
class TestAll(unittest.CheckAll):
module = name_of_module_to_check
skip = [names, to, skip]
which scans the source of module, extracts all the public names, and
fails if any of them (other than those listed in skip) are missing from
__all__. If the source is unavailable, the test is skipped rather than
passing.
--
Steve
More information about the Python-ideas
mailing list