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!newsfeed4a.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'value,': 0.03; 'skip:" 60': 0.05; 'subject:help': 0.07; 'raised.': 0.09; 'valueerror': 0.09; 'def': 0.14; '"with"': 0.16; 'duplicate': 0.18; 'tests': 0.18; 'to:name:python-list@python.org': 0.20; 'trying': 0.22; 'skip:( 40': 0.23; '(most': 0.24; 'raise': 0.24; 'second': 0.24; 'skip:t 40': 0.27; 'message-id:@mail.gmail.com': 0.28; '**kwargs)': 0.29; 'skip:& 70': 0.29; "skip:' 10": 0.30; 'work.': 0.30; 'maybe': 0.31; 'error.': 0.31; 'skip:_ 10': 0.32; 'class': 0.33; 'int': 0.33; 'traceback': 0.33; 'skip:& 10': 0.34; 'file': 0.34; 'add': 0.34; 'received:google.com': 0.34; 'to:addr:python- list': 0.35; 'false': 0.35; 'skip:" 50': 0.35; 'skip:& 60': 0.35; 'but': 0.36; 'should': 0.37; 'skip:s 40': 0.38; 'test': 0.39; 'to:addr:python.org': 0.39; 'skip:t 20': 0.40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vincentdavis.net; s=google; h=mime-version:from:date:message-id:subject:to:content-type; bh=cR6iuEBk14rrxTGDLr+S87Zp84DtUH/Pzio0GKDcYBc=; b=F38CsfcGhnEa2MlaGAc0Oir0078Zp0iD7D2HQ0b+6aInBkejuLsG9gYqq3QiUc4P4f MLQHj3dUzQPWej0cxE5Aiq1ppD9c9xjCoJQqpyzoRznBicZ4Rj3+FuCbQq6TU+gogGO7 SyNxSnyFffrA6FdOUSD2smQrvJHcuU4WJxTdk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=cR6iuEBk14rrxTGDLr+S87Zp84DtUH/Pzio0GKDcYBc=; b=QEeIpEMz1SLDy4spedplJ1yX0PwyirO36G+IPNhn12dAE1gj+4S3+brZILWFH91cA8 /Kk+pwDppl0RCVGTHJPin0YRCnTssUNQN7PIq4UJTQ5tcHWMnH6HSkK03oEXyU69YohZ J0dmf3vmBxQCSYstvwax6bt+zprA7YV5drKm8Obghvwdog6TpUWPFNFqwTwsWMLK/K5e paUkwJLH8kxu5SXY1pIDSeLfesCkGwIaXAQ9HRbkUB0Pr/z0IyzfyoeXIm7hvaCLCnqL SpECec85w34QptmIjEhe2SLaVo6tTPxoDKsZgt2CihOYnP0oBjNtPRNoT4VjUTm+Dg+B yFUQ== X-Gm-Message-State: ALoCoQmPtZ+m/FP7Ob1w2BdDL7MTGBH55eghgSWz6ZF8NCVCQ3rRD7uYAvTaJx/8AeKmyjjb9p7C X-Received: by 10.202.212.68 with SMTP id l65mr20978163oig.89.1432764587813; Wed, 27 May 2015 15:09:47 -0700 (PDT) MIME-Version: 1.0 From: Vincent Davis Date: Wed, 27 May 2015 16:09:27 -0600 Subject: assertRaises() help To: "python-list@python.org" Content-Type: multipart/alternative; boundary=001a113cab984dc72005171780b6 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 90 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432764591 news.xs4all.nl 2962 [2001:888:2000:d::a6]:40654 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91328 --001a113cab984dc72005171780b6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=3D 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=3DTrue))) self.assertTrue(isnull(to_datetime('2015-02-29', format=3D"%Y-%m-%d= ", coerce=3DTrue))) self.assertTrue(isnull(to_datetime('2015-02-32', format=3D"%Y-%m-%d= ", coerce=3DTrue))) self.assertTrue(isnull(to_datetime('2015-04-31', format=3D"%Y-%m-%d= ", coerce=3DTrue))) def test_day_not_in_month_coerce_false(self): self.assertRaises(ValueError, to_datetime, '2015-02-29', coerce=3DFalse) what I get is FAIL: test_day_not_in_month_coerce_false (pandas.tests.test_tseries.TestDaysInMonth) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/vmd/GitHub/pandas_vmd/pandas/tests/test_tseries.py", line 747, in test_day_not_in_month_coerce_false self.assertRaises(ValueError, to_datetime, '2015-02-29', coerce=3DFalse= ) File "/Users/vmd/GitHub/pandas_vmd/pandas/util/testing.py", line 1576, in assertRaises _callable(*args, **kwargs) File "/Users/vmd/GitHub/pandas_vmd/pandas/util/testing.py", line 1640, in __exit__ raise AssertionError("{0} not raised.".format(name)) AssertionError: ValueError not raised. >From the docs maybe I should be using a "with" statement=E2=80=8B. Vincent Davis 720-301-3003 --001a113cab984dc72005171780b6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I am trying to add a test to pandas Int the first case I a= ssert that I get a NaT value, in the second I what to test that I get a val= ue error.
def
test_day_not_in_month_coerce_true
() works
I am t= rying to duplicate them with coerce=3D
False which
will give a Value= Error but I cant get the tests to work.


class TestDaysInMonth(tm= .TestCase):
=C2=A0 =C2=A0 def test_day_not_in_month_coerce_true(self):=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.assertTrue(isnull(to_datetime('2015-= 02-29', coerce=3DTrue)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.assertTrue= (isnull(to_datetime('2015-02-29', format=3D"%Y-%m-%d", co= erce=3DTrue)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.assertTrue(isnull(to_dat= etime('2015-02-32', format=3D"%Y-%m-%d", coerce=3DTrue)))=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.assertTrue(isnull(to_datetime('201= 5-04-31', format=3D"%Y-%m-%d", coerce=3DTrue)))
=C2=A0 =C2= =A0 def test_day_not_in_month_coerce_false(self):
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 self.assertRaises(ValueError, to_datetime, '2015-02-29', coe= rce=3DFalse)

what I get is

FAIL: test_day_not_in_month_coerc= e_false (pandas.tests.test_tseries.TestDaysInMonth)
--------------------= --------------------------------------------------
Traceback (most recen= t call last):
=C2=A0 File "/Users/vmd/GitHub/pandas_vmd/pandas/test= s/test_tseries.py", line 747, in test_day_not_in_month_coerce_false=C2=A0 =C2=A0 self.assertRaises(ValueError, to_datetime, '2015-02-29&#= 39;, coerce=3DFalse)
=C2=A0 File "/Users/vmd/GitHub/pandas_vmd/pand= as/util/testing.py", line 1576, in assertRaises
=C2=A0 =C2=A0 _call= able(*args, **kwargs)
=C2=A0 File "/Users/vmd/GitHub/pandas_vmd/pan= das/util/testing.py", line 1640, in __exit__
=C2=A0 =C2=A0 raise As= sertionError("{0} not raised.".format(name))
AssertionError: V= alueError not raised.

From the docs may= be I should be using a "with" statement=E2=80=8B.


Vi= ncent Davis
720-301-3003
--001a113cab984dc72005171780b6--