Skip to content

Fix trailing current date zeros flaky test_format problem #14638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -937,6 +937,15 @@ def test_format(self):

self.strIndex[:0].format()

# GH 14626
def datetime_now_without_trailing_zeros(self):
now = datetime.now()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so put this inside the other function (as it's just used there)


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)
Expand Down