<div class="gmail_quote">On Fri, Jan 20, 2012 at 2:15 AM, Ulrich Eckhardt <span dir="ltr"><<a href="mailto:ulrich.eckhardt@dominolaser.com">ulrich.eckhardt@dominolaser.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am 19.01.2012 21:45, schrieb Jabba Laci:<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In a unit test, I want to verify that a function returns a<br>
cookielib.LWPCookieJar object. What is the correct way of doing that?<br>
<br>
1) First I tried to figure out its type with type(return_value) but it<br>
is<type 'instance'><br>
</blockquote>
<br></div>
I'm not sure where the problem here is and where exactly you are seeing this. This might even indicate a problem with how the returned type is constructed.<br></blockquote></div><br>This just means that LWPCookieJar is an old-style class:<br>
<br>>>> class Foo: pass<br>...<br>>>> type(Foo())<br><type 'instance'><br>>>> Foo().__class__<br><class __main__.Foo at 0x01DC4CE0><br><br>So for type checks here the __class__ attribute should be used, not the type function. isinstance is better for instance checks though in either case.<br>
<br>Cheers,<br>Ian<br><div style id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup{position: absolute;z-index: 9999;padding: 0px 0px;margin-left: 0px;margin-top: 0px;overflow: hidden;word-wrap: break-word;color: black;font-size: 10px;text-align: left;line-height: 130%;}</style>