Skip to content

Commit 3552dc0

Browse files
MykolaGolubyevjreback
authored andcommitted
TST: Fix trailing current date zeros flaky test_format problem
closes #14626 Author: Mykola Golubyev <[email protected]> Closes #14638 from MykolaGolubyev/issue-14626 and squashes the following commits: 166ec23 [Mykola Golubyev] Inline datetime_now_without_trailing_zeros within test_format 68a72a7 [Mykola Golubyev] Fix trailing current date zeros flaky test_format problem
1 parent f8bd08e commit 3552dc0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pandas/tests/indexes/test_base.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,19 @@ def test_summary(self):
913913
def test_format(self):
914914
self._check_method_works(Index.format)
915915

916-
index = Index([datetime.now()])
916+
# GH 14626
917+
# our formatting is different by definition when we have
918+
# ms vs us precision (e.g. trailing zeros);
919+
# so don't compare this case
920+
def datetime_now_without_trailing_zeros():
921+
now = datetime.now()
922+
923+
while str(now).endswith("000"):
924+
now = datetime.now()
925+
926+
return now
927+
928+
index = Index([datetime_now_without_trailing_zeros()])
917929

918930
# windows has different precision on datetime.datetime.now (it doesn't
919931
# include us since the default for Timestamp shows these but Index

0 commit comments

Comments
 (0)