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


Groups > comp.lang.python > #91335

Re: assertRaises() help

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'value,': 0.03; 'subject:help': 0.07; 'raised.': 0.09; 'skip:> 40': 0.09; 'valueerror': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.14; '"with"': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'running:': 0.16; 'simpson': 0.16; 'wrote:': 0.16; 'duplicate': 0.18; 'tests': 0.18; 'first,': 0.20; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'trying': 0.22; 'cheers,': 0.24; 'seems': 0.24; 'header:In-Reply-To:1': 0.24; 'raise': 0.24; 'second': 0.24; 'header:User-Agent:1': 0.26; 'skip:t 40': 0.27; "skip:' 10": 0.30; 'work.': 0.30; 'maybe': 0.31; 'error.': 0.31; 'int': 0.33; 'received:com.au': 0.33; 'add': 0.34; 'skip:> 10': 0.35; 'but': 0.36; 'should': 0.37; 'subject:: ': 0.37; 'skip:s 40': 0.38; 'test': 0.39; 'does': 0.39; 'skip:t 20': 0.40; 'content-disposition:inline': 0.60; 'your': 0.60; 'here': 0.66; 'cameron': 0.66; '>from': 0.76; 'hand': 0.82; '>def': 0.84; 'bulb': 0.84; 'have?': 0.84
Date Thu, 28 May 2015 08:55:54 +1000
From Cameron Simpson <cs@zip.com.au>
To Vincent Davis <vincent@vincentdavis.net>
Cc "python-list@python.org" <python-list@python.org>
Subject Re: assertRaises() help
MIME-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Disposition inline
Content-Transfer-Encoding 8bit
In-Reply-To <CALyJZZV9DjUbyYRfGoaWzPG1FVnVx0+AsSOyud_ZOyE914A55Q@mail.gmail.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <CALyJZZV9DjUbyYRfGoaWzPG1FVnVx0+AsSOyud_ZOyE914A55Q@mail.gmail.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=L/MkHYj8 c=1 sm=1 tr=0 a=rgDbx50tNA2z7xLXQOoruw==:117 a=rgDbx50tNA2z7xLXQOoruw==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=J0QyKEt1u0cA:10 a=IkcTkHD0fZMA:10 a=vrnE16BAAAAA:8 a=h1PgugrvaO0A:10 a=mf9G4lZGAAAA:8 a=T-Scius0ykv_7o0zkggA:9 a=QEXdDO2ut3YA:10
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.109.1432768581.5151.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1432768581 news.xs4all.nl 2848 [2001:888:2000:d::a6]:41125
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:91335

Show key headers only | View raw


On 27May2015 16:09, Vincent Davis <vincent@vincentdavis.net> wrote:
>I am trying to add a test to pandas Int the first case I assert that I get
>a NaT value, in the second I what to test that I get a value error.
>def
>test_day_not_in_month_coerce_true
>() works
>I am trying to duplicate them with coerce=
>False which
>will give a ValueError but I cant get the tests to work.
>
>
>class TestDaysInMonth(tm.TestCase):
>    def test_day_not_in_month_coerce_true(self):
>        self.assertTrue(isnull(to_datetime('2015-02-29', coerce=True)))
>        self.assertTrue(isnull(to_datetime('2015-02-29', format="%Y-%m-%d",
>coerce=True)))
>        self.assertTrue(isnull(to_datetime('2015-02-32', format="%Y-%m-%d",
>coerce=True)))
>        self.assertTrue(isnull(to_datetime('2015-04-31', format="%Y-%m-%d",
>coerce=True)))
>    def test_day_not_in_month_coerce_false(self):
>        self.assertRaises(ValueError, to_datetime, '2015-02-29',
>coerce=False)
>
>what I get is
>
>FAIL: test_day_not_in_month_coerce_false
>(pandas.tests.test_tseries.TestDaysInMonth)
>----------------------------------------------------------------------
[...]
>AssertionError: ValueError not raised.
>
>From the docs maybe I should be using a "with" statement​.

Unlikely.

First, test your test by hand running:

  to_datetime('2015-02-29', coerce=False)

_Does_ it raise ValueError?

Cheers,
Cameron Simpson <cs@zip.com.au>

Q: How many user support people does it take to change a light bulb?
A: We have an exact copy of the light bulb here and it seems to be
   working fine.  Can you tell me what kind of system you have?

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


Thread

Re: assertRaises() help Cameron Simpson <cs@zip.com.au> - 2015-05-28 08:55 +1000

csiph-web