[issue25699] Easier way to specify reduced globals for doctest

2016-10-02 Thread John Mark Vandenberg

John Mark Vandenberg added the comment:

pyflakes does assume doctest run with a copy of the module scope.


However when there is an __all__, the module scope as seen by other modules 
'should' be only items in __all__.  If a doctest is included in documentation, 
it 'should' only use names that are in __all__.

In addition, pyflakes has an outstanding feature request 
(https://bugs.launchpad.net/pyflakes/+bug/1178807/comments/8) that doctest run 
as if they are an independent module, and need to import everything that they 
use, so that each doctest is self-contained.

pyflakes can build support for both of those needs within the package.  No 
worries.  If you cant see a broader need for these, please close.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25699] Easier way to specify reduced globals for doctest

2015-11-23 Thread R. David Murray

R. David Murray added the comment:

I don't understand what the problem is you are trying to solve.  Doctests are 
designed to run with a copy of the module global scope.  If pyflakes does not 
understand that, it is a pyflakes bug, but it doesn't sound like that's the 
issue.  It sounds like you want to use a different global scope, in which case 
I think the onus is on you to deal with it.

I'm -1 on this request.  I don't think the additional complexity is worthwhile.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25699] Easier way to specify reduced globals for doctest

2015-11-22 Thread John Mark Vandenberg

New submission from John Mark Vandenberg:

Currently doctest.testmod `globals` defaults to including everything in the 
module scope, and tools like pyflakes assume that doctests run with globals as 
a copy of __dict__ .

It is relatively simple to exclude everything using doctest.testmod(globs={}).

However to use a limited scope, such as only including attributes in __all__, 
we need to use `doctest.testmod(globs=[(name, globals()[name]) for name in 
__all__])`

However those solutions require that each module includes a `if __name__ == 
"__main__":` block that invokes doctest.testmod, and then other doctest related 
tools (pyflakes, nose, etc) need to *parse* the invocation to determine the 
desired globals contents.

It would be easier to control the globals using a module attribute that works 
like __all__, so that all doctest tools could easily determine the desired 
contents of globals.

e.g. the following could provide a sane reduced globals for doctests

__test_all__ = __all__ = ['foo']

As people sometimes add docstrings/doctest for functions not exported in 
__all__ for external use, in addition to the list of symbols in __test_all__, 
the doctest globals should include the function/class which the 
docstring/doctest is attached to.

See https://bugs.launchpad.net/pyflakes/+bug/1178807 for background to this 
enhancement request.

--
components: Tests
messages: 255111
nosy: John.Mark.Vandenberg
priority: normal
severity: normal
status: open
title: Easier way to specify reduced globals for doctest
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com