[issue26878] Allow doctest to deep copy globals

2020-11-24 Thread Irit Katriel
Change by Irit Katriel : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue26878] Allow doctest to deep copy globals

2016-04-29 Thread DqASe
DqASe added the comment: I see your point. I thought it can still be useful in these scenarios: 1. when doc/testing tens of methods of a specific class. Instantiation of the class is repetitive (DRY principle). 2. Instantiation can be expensive (e.g. from network) 3. To behave

[issue26878] Allow doctest to deep copy globals

2016-04-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Fri, Apr 29, 2016 at 10:09:46AM +, DqASe wrote: > Added file: http://bugs.python.org/file42649/x.py Ah, I see! That makes sense now. Thanks. Why don't you just set the initial state of the lists in the doctests? That makes much better documentation.

[issue26878] Allow doctest to deep copy globals

2016-04-29 Thread DqASe
DqASe added the comment: I'd like each test to see the same environment (including variables contents). Deepcopying extraglobs argument at call time is not sufficient because it is only done once, not before each test. -- Added file: http://bugs.python.org/file42649/x.py

[issue26878] Allow doctest to deep copy globals

2016-04-28 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm afraid I can't quite see what the problem is. If you're passing your own globs argument, can't you deepcopy it yourself? Could you show a minimal, short example demonstrating the issue please? -- nosy: +steven.daprano versions: +Python 3.6

[issue26878] Allow doctest to deep copy globals

2016-04-28 Thread DqASe
DqASe added the comment: Alternatively, add an option like deepglobs={...} . The dictionary argument would be deep-copied at each test and added to the environment. -- ___ Python tracker

[issue26878] Allow doctest to deep copy globals

2016-04-28 Thread DqASe
Changes by DqASe : -- components: +Tests -Library (Lib) ___ Python tracker ___ ___

[issue26878] Allow doctest to deep copy globals

2016-04-28 Thread DqASe
New submission from DqASe: Currently doctest makes shallow copies of the environment or globs argument. This is somewhat un-symmetrical: on the one hand, a test cannot see variables created by another, but on the other, it can alter mutable objects. This is inconvenient e.g. when