Skip to content

Commit 1b9f9f4

Browse files
busunkim96tseaver
authored andcommitted
Fix tests broken in PR #8227. (#8273)
1 parent b612632 commit 1b9f9f4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

google/cloud/logging/handlers/transports/background_thread.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from __future__ import print_function
2121

2222
import atexit
23+
import datetime
2324
import logging
2425
import sys
2526
import threading
@@ -261,7 +262,7 @@ def enqueue(
261262
"labels": labels,
262263
"trace": trace,
263264
"span_id": span_id,
264-
"timestamp": datetime.utcfromtimestamp(record.created),
265+
"timestamp": datetime.datetime.utcfromtimestamp(record.created),
265266
}
266267
)
267268

tests/unit/handlers/transports/test_background_thread.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import time
1516
import logging
1617
import unittest
1718

@@ -243,7 +244,9 @@ def test__main_thread_terminated_non_empty_queue(self):
243244
worker = self._make_one(_Logger(self.NAME))
244245

245246
self._start_with_thread_patch(worker)
246-
worker.enqueue(mock.Mock(), "")
247+
record = mock.Mock()
248+
record.created = time.time()
249+
worker.enqueue(record, "")
247250
worker._main_thread_terminated()
248251

249252
self.assertFalse(worker.is_alive)
@@ -253,7 +256,9 @@ def test__main_thread_terminated_did_not_join(self):
253256

254257
self._start_with_thread_patch(worker)
255258
worker._thread._terminate_on_join = False
256-
worker.enqueue(mock.Mock(), "")
259+
record = mock.Mock()
260+
record.created = time.time()
261+
worker.enqueue(record, "")
257262
worker._main_thread_terminated()
258263

259264
self.assertFalse(worker.is_alive)
@@ -431,6 +436,7 @@ def log_struct(
431436
labels=None,
432437
trace=None,
433438
span_id=None,
439+
timestamp=None,
434440
):
435441
from google.cloud.logging.logger import _GLOBAL_RESOURCE
436442

0 commit comments

Comments
 (0)