Skip to content Skip to sidebar Skip to footer
Showing posts with the label Mocking

Mock Builtin 'open" Function When Used In Contextlib

I know this question has been asked before, but I have a particular problem, meaning I want the moc… Read more Mock Builtin 'open" Function When Used In Contextlib

How Do I Test That I'm Calling Pickle.dump() Correctly?

I want to test this method: class Data(object): def save(self, filename=''): i… Read more How Do I Test That I'm Calling Pickle.dump() Correctly?

Mock Exception With Side Effect Raised In Class Method And Caught In Calling Method Gives 'did Not Raise'

Using side_effect, I am trying to raise an exception when a mock is called but I get a DID NOT RAIS… Read more Mock Exception With Side Effect Raised In Class Method And Caught In Calling Method Gives 'did Not Raise'

Return Value Not Set As Intended When Mocking A Method With @mock.patch.object

My test should with reason succeed as I'm giving a return value with mocker.return_value, which… Read more Return Value Not Set As Intended When Mocking A Method With @mock.patch.object

Mocking Python Class In Unit Test And Verifying An Instance

I'm trying to unit test an SFTP helper class that makes some calls to the pysftp module. I want… Read more Mocking Python Class In Unit Test And Verifying An Instance

How To Mock A Redis Client In Python?

I just found that a bunch of unit tests are failing, due a developer hasn't mocked out the depe… Read more How To Mock A Redis Client In Python?