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.

Author terry.reedy
Recipients serhiy.storchaka, terry.reedy
Date 2017-09-23.17:52:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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' = '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.
Date User Action Args
2017-09-23 17:52:59terry.reedysetrecipients: + terry.reedy, serhiy.storchaka
2017-09-23 17:52:59terry.reedysetmessageid: <>
2017-09-23 17:52:59terry.reedylinkissue31559 messages
2017-09-23 17:52:59terry.reedycreate