Python Mocking of Boolean Function
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Luau
--
Chapters
00:00 Python Mocking Of Boolean Function
00:33 Accepted Answer Score 2
00:50 Thank you
--
Full question
https://stackoverflow.com/questions/3094...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #python27 #unittesting #mocking
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Luau
--
Chapters
00:00 Python Mocking Of Boolean Function
00:33 Accepted Answer Score 2
00:50 Thank you
--
Full question
https://stackoverflow.com/questions/3094...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #python27 #unittesting #mocking
#avk47
ACCEPTED ANSWER
Score 2
From your function here, stream seems to be a class.
Since you create an instance of that class and then you call the open method on that instance, you need to do mock_stream.return_value.open.return_value = False in the test function.