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

Python3 Mock Doesn't Work For All Paths

The Production file (production_file.py) is: class MyError(Exception): pass class MyClass: … Read more Python3 Mock Doesn't Work For All Paths

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__?

Adding Mock Objects In Python

My code under test does sth like this: def to_be_tested(x): return round((x.a + x.b).c()) I woul… Read more Adding Mock Objects In 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

Mocking Render To Response With Pyramid

I have a decorator that looks like so: def validate_something(func): def validate_s(request): … Read more Mocking Render To Response With Pyramid

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?