Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19139
| 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 | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.071 |
| X-Spam-Evidence | '*H*': 0.86; '*S*': 0.01; 'test,': 0.04; '(using': 0.05; 'attributes': 0.05; 'cc:addr:python-list': 0.15; 'subject:function': 0.16; 'wrote:': 0.16; 'that?': 0.18; 'jan': 0.19; 'seems': 0.19; 'cheers,': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.25; 'somewhere': 0.25; 'pm,': 0.26; 'function': 0.27; 'received:209.85.220': 0.27; 'message-id:@mail.gmail.com': 0.28; 'explicit': 0.28; 'cc:addr:python.org': 0.29; 'object.': 0.30; 'chris': 0.30; '(as': 0.30; 'correct': 0.31; 'thu,': 0.32; 'hi,': 0.34; 'probably': 0.35; 'however,': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'received:209': 0.39; 'doing': 0.39; 'subject:: ': 0.39; 'might': 0.40; 'here.': 0.64; 'alternative': 0.65; '19,': 0.68; 'favor': 0.70; '12:45': 0.84; 'sender:addr:chris': 0.84; 'subject:value': 0.84; 'url:rebertia': 0.84; 'technique': 0.93; 'absolutely': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=k7FWQmUw5KMHK+vuxvMEtQWBYYm0u4yWwh0Us7DZ6dY=; b=NdEPi22a4y/is/KjJWtVYjUwvkUnqGl3qdgxM3Q97QHQu7xsEXh2iJXbWzEuA6ZffB xWx6O18IQXXABtXn5lB+T5AHYJ5elc/LyTAc+Q3/GSMfkVOw3GA2B2vyC+L1YUXNs3qU 2Tua5yzupkEWQikdv3e7p13b2u1sNtiAAIRpY= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <CAOuJsM=DonsS_Th=XEx72z_5HjmdvdE4HOrJzmB4NuBt3fVSSw@mail.gmail.com> |
| References | <CAOuJsM=DonsS_Th=XEx72z_5HjmdvdE4HOrJzmB4NuBt3fVSSw@mail.gmail.com> |
| Date | Thu, 19 Jan 2012 13:13:22 -0800 |
| X-Google-Sender-Auth | AEosYbjhDG_tcEN54jy24ZK1sNE |
| Subject | Re: verify the return value of a function |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Jabba Laci <jabba.laci@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | Python mailing list <python-list@python.org> |
| 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.4873.1327007605.27778.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1327007606 news.xs4all.nl 6868 [2001:888:2000:d::a6]:48565 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:19139 |
Show key headers only | View raw
On Thu, Jan 19, 2012 at 12:45 PM, Jabba Laci <jabba.laci@gmail.com> wrote: > 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? <snip> > 3) isinstance(return_value, cookielib.LWPCookieJar) seems to be the > best way, however somewhere I read that using isinstance is > discouraged Explicit typechecking is often discouraged in favor of duck typing. However, if you want to do explicit typechecking (as one might in unit tests), then isinstance() is absolutely the technique to use. The alternative would be to check for the specific attributes of LWPCookieJar that you're relying upon (using hasattr() or similar), but that's probably overkill here. Cheers, Chris -- http://rebertia.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: verify the return value of a function Chris Rebert <clp2@rebertia.com> - 2012-01-19 13:13 -0800
csiph-web