Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'test,': 0.04; 'to:name:python mailing list': 0.09; 'subject:function': 0.16; 'thanks,': 0.18; 'that?': 0.18; 'seems': 0.19; 'figure': 0.23; 'somewhere': 0.25; 'function': 0.27; 'tried': 0.27; 'message- id:@mail.gmail.com': 0.28; "skip:' 10": 0.29; 'object.': 0.30; 'received:209.85.210.46': 0.30; 'received:mail- pz0-f46.google.com': 0.30; 'correct': 0.31; 'to:addr:python-list': 0.33; 'hi,': 0.34; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'received:209': 0.39; 'doing': 0.39; 'to:addr:python.org': 0.40; 'type': 0.60; 'subject:value': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=ujOq0VXEOaDJpjQO0r5jJETfPOh2q2GaIRMm7FS8cZU=; b=DifE7bdsc8UeLcioUn51ESkOKm33IvMigZeUw/jEcIKcggOM0uGsoYcJ6gK0pT22ST czuDRWNUK4TFfNJbFoupZ2IGkUjAXJnCeR1bCssfgiM719DlyZqgWsEs7BGcvh32ehFX NxrMCfOn2SU4MPyVH4kX+l8YeLL6ko21b9IlA= MIME-Version: 1.0 From: Jabba Laci Date: Thu, 19 Jan 2012 21:45:38 +0100 Subject: verify the return value of a function To: Python mailing list Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1327005963 news.xs4all.nl 6976 [2001:888:2000:d::a6]:44840 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19138 Hi, In a unit test, I want to verify that a function returns a cookielib.LWPCookieJar object. What is the correct way of doing that? 1) First I tried to figure out its type with type(return_value) but it is 2) return_value.__class__ .__name__ gives 'LWPCookieJar', which is bettter 3) isinstance(return_value, cookielib.LWPCookieJar) seems to be the best way, however somewhere I read that using isinstance is discouraged Thanks, Laszlo