I want a dummy object I can instantiate in python and programmatically create attributes for via setattr().
I tried it on the built in object but probably for a good reason that didn't work.
What base object can I use in python for such purposes without actually defining one myself?
You can't use mock = object(), instead just create a Mock derived from object
class Mock(object):
pass
mock = Mock()
setattr(mock, 'test', 'whatever')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With