Unmockify#141
Conversation
Some of the Mock objects "leaked out" into other tests, especially runner.path_to_enlightenment.koans, which was untestable after it had been replaced with a Mock.
Python 2 and 3: test_sensei.py replaced some methods of runner.mockable_test_result.MockableTestResult with new Mock objects. I did not experience these "leaking" into other tests, but they could have. Also, removed unused "import sys" from both 2 and 3 versions.
|
I encountered this because I was trying to test a version of Is there any interest in this? (I'm not sure if there's a better place to ask this kind of question. Issues, maybe?) |
|
I'd be interested to see what your alternative Thanks for the PR! :-) |
Python 2 and 3: Replaces several
<globally_visible_thing> = Mock()assignments withwith patch(...):andwith patch_object(...):blocks, to preventMockobjects leaking out of their tests into others.For example, after
test_mountainortest_senseiranpath_to_enlightenment.koans = Mock(), it was impossible to test thekoansfunction --- it just kept returningMock. (That specific mock seemed completely unneeded anyway, so I removed it. The_runner_tests.pyoutputs didn't change.)