Terry J. Reedy added the comment:

browser.transform_children, when called the first time on a dict of children 
nodes, rebinds the name attribute of Classes with bases*. Tests that called the 
real browser.transform_children the first time on a node mutate the global 
mock_pyclbr_tree.  When the tests are re-run in the same process, tests 
initially run before the mutation are also run after the mutation.

*This is not an issue in current real use.  IDLE gets a new tree each time a 
module browser is opened.  The current tree widget calls GetSublist and hence 
transform_children at most once per node as it caches the result for each node. 
 But don't know what ttk.Treeview does and do know that tests can make multiple 
calls.  

Restoring the tree with
def tearDownModule():
    C0.name = 'C0'
    C1.name = 'C1'
fixes the failures found when rerunning the test module in the same process, 
but not the underlying problem of order dependence.

Instead, I added immediate calls to transform_children so that the mock tree is 
never mutated thereafter by any of the tests.  The subsequent class checks that 
the initial name replacements are correct.  All tests see the tree in the same 
state, so there should not be any order dependence left.

Testing global function calls in a testcase is slightly awkward, but the 
testcase follows immediately, and making the tree and its nodes global 
simplifies the tests that use the tree.

I checked that running test_pyclbr and test_idle twice each succeeds.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31559>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to