From 68a72a796b1b235f65298e208ff1dbbc076e0bd6 Mon Sep 17 00:00:00 2001 From: Mykola Golubyev Date: Fri, 11 Nov 2016 09:30:31 -0500 Subject: [PATCH 1/2] Fix trailing current date zeros flaky test_format problem --- pandas/tests/indexes/test_base.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index b839ed6331457..e70e1c3b170e5 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -913,7 +913,7 @@ def test_summary(self): def test_format(self): self._check_method_works(Index.format) - index = Index([datetime.now()]) + index = Index([self.datetime_now_without_trailing_zeros()]) # windows has different precision on datetime.datetime.now (it doesn't # include us since the default for Timestamp shows these but Index @@ -937,6 +937,15 @@ def test_format(self): self.strIndex[:0].format() + # GH 14626 + def datetime_now_without_trailing_zeros(self): + now = datetime.now() + + while str(now).endswith("000"): + now = datetime.now() + + return now + def test_format_with_name_time_info(self): # bug I fixed 12/20/2011 inc = timedelta(hours=4) From 166ec231afbf28e07f59fe604bcab4c172712819 Mon Sep 17 00:00:00 2001 From: Mykola Golubyev Date: Fri, 11 Nov 2016 10:27:32 -0500 Subject: [PATCH 2/2] Inline datetime_now_without_trailing_zeros within test_format --- pandas/tests/indexes/test_base.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index e70e1c3b170e5..27413edcb3701 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -913,7 +913,16 @@ def test_summary(self): def test_format(self): self._check_method_works(Index.format) - index = Index([self.datetime_now_without_trailing_zeros()]) + # GH 14626 + def datetime_now_without_trailing_zeros(): + now = datetime.now() + + while str(now).endswith("000"): + now = datetime.now() + + return now + + index = Index([datetime_now_without_trailing_zeros()]) # windows has different precision on datetime.datetime.now (it doesn't # include us since the default for Timestamp shows these but Index @@ -937,15 +946,6 @@ def test_format(self): self.strIndex[:0].format() - # GH 14626 - def datetime_now_without_trailing_zeros(self): - now = datetime.now() - - while str(now).endswith("000"): - now = datetime.now() - - return now - def test_format_with_name_time_info(self): # bug I fixed 12/20/2011 inc = timedelta(hours=4)