Timeline for What is the best/most Pythonic way to mock a private function?
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 8, 2016 at 9:00 | comment | added | RemcoGerlich | @AvivCohn: well if it's an implementation detail that you don't want to test directly, you probably shouldn't mock it when testing func. | |
| Nov 8, 2016 at 5:00 | history | edited | user949300 | CC BY-SA 3.0 | added 156 characters in body |
| Nov 8, 2016 at 4:55 | comment | added | user949300 | Private does not necessarily mean "implementation detail". A private method may (or may not) be worthy of testing - but sounds like it is for your case. As for most "Pythonic", my python experience is very limited so others should answer that. | |
| Nov 8, 2016 at 1:57 | comment | added | Aviv Cohn | Thanks for your answer. Two questions: first, _generate_something is a 'private' function, an 'implementation detail', while func is a public function of the module. Is it good practice and common to just test _generate_something directly (i.e. test private methods)? Secondly, I understand what you mean about func not being wotthwhile to test anyway. But still, I'd like an answer to the question of what is the good and Pythonicbway to mock _do_something. Which of the four approaches is the best? | |
| Nov 8, 2016 at 1:45 | history | answered | user949300 | CC BY-SA 3.0 |