derwiki-adroll / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

documentation addition: mocking objects with attribute "name" #199

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Due to "name" being a argument to the MagicMock constructor, it would be useful 
to add info to the documentation about how to create a mock with an attribute 
named "name".  Possible contents for the "Attaching Mocks as Attributes" 
section:

Since "name" is an argument to the MagicMock constructor, if you want your 
object to have the attribute "name" use the configure_mock call.

>>> mock = MagicMock()
>>> mock.configure_mock(name='my_name')
>>> mock.name
'my_name'

Original issue reported on code.google.com by ctrud...@knexxlocal.com on 29 Jan 2013 at 5:20

GoogleCodeExporter commented 9 years ago
Yep, good addition.

Original comment by fuzzyman on 29 Jan 2013 at 5:21

GoogleCodeExporter commented 9 years ago
Although this also works fine:

mock.name = 'my name'

Original comment by fuzzyman on 29 Jan 2013 at 5:22

GoogleCodeExporter commented 9 years ago
Done, thanks.

Original comment by fuzzyman on 18 Mar 2013 at 10:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
thanks, works for me

Original comment by dmitry.t...@gmail.com on 23 Jul 2014 at 4:43