Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19138

verify the return value of a function

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 <jabba.laci@gmail.com>
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 <jabba.laci@gmail.com>
Date Thu, 19 Jan 2012 21:45:38 +0100
Subject verify the return value of a function
To Python mailing list <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4872.1327005963.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


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 <type 'instance'>

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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

verify the return value of a function Jabba Laci <jabba.laci@gmail.com> - 2012-01-19 21:45 +0100
  Re: verify the return value of a function Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-01-20 10:15 +0100
  Re: verify the return value of a function Roy Smith <roy@panix.com> - 2012-01-20 09:24 -0500

csiph-web