xds/testing: fix usage of datetime astimezone (#27010)

It caused failure:

Traceback (most recent call last):
  File "tools/run_tests/run_xds_tests.py", line 3096, in <module>
    datetime.datetime.now().astimezone().strftime("%Y-%m-%dT%H:%M:%S %Z"))
ValueError: astimezone() cannot be applied to a naive datetime
pull/27110/head
Menghan Li 3 years ago committed by GitHub
parent 1d9a242931
commit 0001d6873d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      tools/run_tests/run_xds_tests.py

@ -3093,7 +3093,8 @@ class GcpState(object):
logging.debug(
"script start time: %s",
datetime.datetime.now().astimezone().strftime("%Y-%m-%dT%H:%M:%S %Z"))
datetime.datetime.now(
datetime.timezone.utc).astimezone().strftime("%Y-%m-%dT%H:%M:%S %Z"))
logging.debug("logging local timezone: %s",
datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo)
alpha_compute = None

Loading…
Cancel
Save