mocksafe.MockProperty

class mocksafe.MockProperty(return_value: T)

Used to mock a property on a mock object.

It holds a single stubbed value.

You can assert calls the same as a mocked method.

See the Mocking page for more details and an example of how to mock, stub, and verify a property.

Apart from creating and stubbing values, you wouldn’t normally interact with this object directly.

See also:

__init__(return_value: T)

Set the initial property value to stub, of generic type T.

The generic type must match the type returned from the property being mocked.

Methods

__setattr__(name, value, /)

Implement setattr(self, name, value).

deleter

Descriptor to obtain a copy of the property with a different deleter.

getter

Descriptor to obtain a copy of the property with a different getter.

nth_call(n)

setter

Descriptor to obtain a copy of the property with a different setter.

Attributes

calls

fdel

fget

fset

name

return_value

Property used to stub the result to return when this mocked property value is retrieved.

value_type