Skip to content

Unmockify#141

Merged
mpirnat merged 2 commits intogregmalcolm:masterfrom
kjc:unmockify
Sep 30, 2016
Merged

Unmockify#141
mpirnat merged 2 commits intogregmalcolm:masterfrom
kjc:unmockify

Conversation

@kjc
Copy link
Copy Markdown
Collaborator

@kjc kjc commented Sep 28, 2016

Python 2 and 3: Replaces several <globally_visible_thing> = Mock() assignments with with patch(...): and with patch_object(...): blocks, to prevent Mock objects leaking out of their tests into others.

For example, after test_mountain or test_sensei ran path_to_enlightenment.koans = Mock(), it was impossible to test the koans function --- it just kept returning Mock. (That specific mock seemed completely unneeded anyway, so I removed it. The _runner_tests.py outputs didn't change.)

kjc added 2 commits September 28, 2016 03:00
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.
@kjc
Copy link
Copy Markdown
Collaborator Author

kjc commented Sep 29, 2016

I encountered this because I was trying to test a version of path_to_enlightenment.koans that imports and loads koans based on the name of the module. It's uglier than I wanted (because about_proxy_object_project.TelevisionTest doesn't fit the pattern), but it might still be easier to manage than dozens-of-imports followed by dozens-of-addTests. Since it's arguments are just a bunch of strings, they could conceivably be moved to an external config file.

Is there any interest in this? (I'm not sure if there's a better place to ask this kind of question. Issues, maybe?)

@mpirnat mpirnat merged commit ade4b6e into gregmalcolm:master Sep 30, 2016
@mpirnat
Copy link
Copy Markdown
Collaborator

mpirnat commented Sep 30, 2016

I'd be interested to see what your alternative path_to_enlightenment looks like... It definitely seems like the intent is to be able to run them in an arbitrary/non-alphabetic order. It'd probably be good to move discussion to a separate issue.

Thanks for the PR! :-)

@kjc kjc deleted the unmockify branch September 30, 2016 16:10
@kjc kjc mentioned this pull request Oct 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants