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

Override Python Function-local Variable In Unittest

I have a method in python (2.7) that does foo, and gives up after 5 minutes if foo didn't work.… Read more Override Python Function-local Variable In Unittest

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

Mock.patch And Multiprocessing

I'm struggling to use mock.patch in a multiprocessing environment while without multiprocessing… Read more Mock.patch And Multiprocessing

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__

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

Patch Not Mocking A Module

I'm trying to mock subprocess.Popen. When I run the following code however, the mock is complet… Read more Patch Not Mocking A Module

How To Permanently Mock Return Value Of A Function In Python Unittest

I have a function # foo.py NUM_SHARDS = 10 def get_shard(shard_key: int) -> int return (shar… Read more How To Permanently Mock Return Value Of A Function In Python Unittest

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