Sorry, yes, I see your original code again now, so yeah I sent you on the wrong track a bit, sorry, (though clearing out some of the clutter hopefully helps).<div><br></div><div>So, your error says your object doesn't have a config attr because it doesn't. All you've done is mocked super so that it returns a mock object, but that object is not really the superclass of DevBuild, and DevBuild never runs Build.__init__, and never sets its own config object.</div>
<div><br></div><div>So, if you want to have a config attr, you have to set it, presumably to a mock object (in addition to patching super or slightly better Build.__init__ to ensure it isn't run).</div><div><br></div>
<div>Julian<span></span></div><div><br>On Thursday, December 20, 2012, Ken Hagler wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Dec 20, 2012, at 9:01 AM, Julian Berman <<a>julian@grayvines.com</a>> wrote:<br>
<br>
> You need to replace in the module under test (can't link to the docs but<br>
> there's a helpful article there if you can't figure it out).<br>
><br>
> Something like:<br>
><br>
> with mock.patch("mymodule.super", create=True) as mock_super:<br>
> mock_super.return_value.config.whatever = 12<br>
> exercise()<br>
> assert()<br>
<br>
Okay I tried this, so now test_init starts:<br>
<br>
with patch('DevBuild.super', create=True) as mock_super:<br>
mock_MakeDevBuild = MagicMock()<br>
mock_super.return_value.config.MakeDevBuild = mock_MakeDevBuild<br>
<br>
This is certainly simpler, but it also produces the same error: "AttributeError: 'DevBuild' object has no attribute 'config'"<br>
--<br>
Ken Hagler<br>
<br>
| <a href="http://www.orange-road.com/" target="_blank">http://www.orange-road.com/</a> |<br>
| And tho' we are not now that strength which in old days |<br>
| Moved earth and heaven, that which we are, we are --Tennyson |<br>
<br>
</blockquote></div>