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

How To Mock A Socket Object Via The Mock Library

How to mock a TCPSocket wrapper for the socket from the Python's standard libary via the mock l… Read more How To Mock A Socket Object Via The Mock Library

Python Propertymock Side Effect With Attributeerror And Valueerror

I am trying to mock a property of a class (@property decorator) and have bumped into this incorrect… Read more Python Propertymock Side Effect With Attributeerror And Valueerror

Concept: Mocking Db Python

I'm working with postgresql and I have used MagicMock to test, but I'm not sure that I have… Read more Concept: Mocking Db Python

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

How To Unit Test Time Based Functions Without Adding Parameters

I created a function that returns seconds left until the next occurrence of that time, but I came a… Read more How To Unit Test Time Based Functions Without Adding Parameters

How Can I Mock Any Function Which Is Not Being Called Directly?

TL;DR How can I patch or mock 'any functions that are not being called/used directly'? Scen… Read more How Can I Mock Any Function Which Is Not Being Called Directly?

Mock A Pyqt Method

I have an existing class which inherits from the PyQT5 classes QWidget and Ui_Dialog. I want to use… Read more Mock A Pyqt Method

Does Someone Have An Example Of Unit-testing A Soap Api With Python Zeep And Mock?

I'm building a Python app that accesses a 3rd party SOAP API with Python-zeep. I want to implem… Read more Does Someone Have An Example Of Unit-testing A Soap Api With Python Zeep And Mock?

Patch - Why Won't The Relative Patch Target Name Work?

I've imported a class from a module, but when I try to patch the class name without it's mo… Read more Patch - Why Won't The Relative Patch Target Name Work?

Python Mock And Libraries That Are Not Installed

I am working on software for a robot, which is normally run on the Raspberry Pi. Let's consider… Read more Python Mock And Libraries That Are Not Installed

How To Mock Just The Method Inside The Class

Trying to write a testcase for my class based function. This is skeleton of my class class Library(… Read more How To Mock Just The Method Inside The Class

Mocking Methods On An Instance Variable In Python

I'm trying to figure out how to properly Mock an instance variable which is an instance of anot… Read more Mocking Methods On An Instance Variable In Python

Max Recursion Depth While Trying To Mock Instance Method

I want to mock an instance method. First I want to modify the arguments and then I want to call the… Read more Max Recursion Depth While Trying To Mock Instance Method

How Do We Ensure That The Calls In The Mock.call_args_list Contain Calls With Arguments At The Same State Of When The Mock Object Was Called?

from mock import Mock j = [] u = Mock() u(j) # At this point u.call_args_list == [call([])] print u… Read more How Do We Ensure That The Calls In The Mock.call_args_list Contain Calls With Arguments At The Same State Of When The Mock Object Was Called?

How Do You Pass Exception Arguments To Python Unittest Mock Side Effect?

How do you pass exceptions that require arguments as mock side_effects? I'm trying to test fo… Read more How Do You Pass Exception Arguments To Python Unittest Mock Side Effect?

Mocking File Objects Or Iterables In Python

Which way is proper for mocking and testing code that iters object returned by open(), using mock l… Read more Mocking File Objects Or Iterables In Python

Running Pytest Tests Against Multiple Backends?

I've built a series of tests (using pytest) for a codebase interacting with the Github API (bot… Read more Running Pytest Tests Against Multiple Backends?

Python PropertyMock Side Effect With AttributeError And ValueError

I am trying to mock a property of a class (@property decorator) and have bumped into this incorrect… Read more Python PropertyMock Side Effect With AttributeError And ValueError