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) ---------------------------------------------------------------------- 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=False) 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​. Vincent Davis 720-301-3003
-- https://mail.python.org/mailman/listinfo/python-list