On 27May2015 16:09, Vincent Davis <vinc...@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 <c...@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?
--
https://mail.python.org/mailman/listinfo/python-list