Skip to content

Commit 63d7a37

Browse files
authored
fix: update library version and fix test failure (GoogleCloudPlatform#8525)
* fix: update library version * debug: view output * fix: set flag to adjust output * fix: use only first line of log * debug: display raw stdout * debug: display raw stdout * fix: strip extra leading output if there * fix: remove unused import * fix: update library version * Don't capture output that won't be used
1 parent 68a236a commit 63d7a37

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

functions/v2/http_logging/main_test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 Google LLC
1+
# Copyright 2023 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the 'License');
44
# you may not use this file except in compliance with the License.
@@ -46,6 +46,13 @@ def test_functions_log_http_should_print_message(app, capsys):
4646
with app.test_request_context(headers={'x-cloud-trace-context': f"{mock_trace}/{mock_span};o=1"}):
4747
main.structured_logging(flask.request)
4848
_, err = capsys.readouterr()
49-
output_json = json.loads(err)
49+
50+
# In some situations, the library adds information before the first
51+
# intended line. Use the next line in that case.
52+
err_lines = err.splitlines()
53+
if len(err_lines) > 1:
54+
err = err_lines[1]
55+
56+
output_json = json.loads(err.splitlines()[0])
5057
for (key, value) in expected.items():
5158
assert value == output_json[key]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
google-cloud-logging==3.1.2
1+
google-cloud-logging==3.2.5
22
functions-framework==3.2.0

0 commit comments

Comments
 (0)