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

How To Mock Python's Datetime.now() In A Class Method For Unit Testing?

I'm trying to write tests for a class that has methods like: import datetime import pytz class… Read more How To Mock Python's Datetime.now() In A Class Method For Unit Testing?

Mock A Remote Host In Python

I am writing some functions, using paramiko, to execute commands and create files on a remote host.… Read more Mock A Remote Host In Python

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

Why Does Mocking 'open' And Returning A Filenotfounderror Raise Attributeerror: __exit__?

Testing by mocking open with a FileNotFoundError raises AttributeError: __exit__. Why is this happe… Read more Why Does Mocking 'open' And Returning A Filenotfounderror Raise Attributeerror: __exit__?

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

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?