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

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

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

Really Weird... Can't Set Attributes Of Built-in/extension Type 'lxml.etree._element'

I've changed attributes for other classes before without issues. _Element is obviously not a bu… Read more Really Weird... Can't Set Attributes Of Built-in/extension Type 'lxml.etree._element'

How Should I Verify A Log Message When Testing Python Code Under Nose?

I'm trying to write a simple unit test that will verify that, under a certain condition, a clas… Read more How Should I Verify A Log Message When Testing Python Code Under Nose?

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

Python 3 - Unittest With Multiple Inputs And Print Statement Using Mocking

I'm studying Python and a few weeks ago I had created a game which the user needs to guess the … Read more Python 3 - Unittest With Multiple Inputs And Print Statement Using Mocking

Pytest - Patched Method Of A Class Does Not Return The Mock Value

My code is fairly simple but i don't understand what is going on : class MyDb : def some_fun… Read more Pytest - Patched Method Of A Class Does Not Return The Mock Value

Mock A Class With Tedious __init__

I have a class that actually connects to a service and does authentication and stuff, but all of th… Read more Mock A Class With Tedious __init__