diff --git a/logging/samples/snippets/export_test.py b/logging/samples/snippets/export_test.py index c9eb18efb8..e7dacd49ee 100644 --- a/logging/samples/snippets/export_test.py +++ b/logging/samples/snippets/export_test.py @@ -13,8 +13,8 @@ # limitations under the License. import os -import re import random +import re import string import time diff --git a/logging/samples/snippets/requirements.txt b/logging/samples/snippets/requirements.txt index 8a52ee5c68..65b84840d3 100644 --- a/logging/samples/snippets/requirements.txt +++ b/logging/samples/snippets/requirements.txt @@ -1,4 +1,4 @@ -google-cloud-logging==3.10.0 -google-cloud-bigquery==3.25.0 -google-cloud-storage==2.17.0 -google-cloud-pubsub==2.22.0 +google-cloud-logging==3.13.0 +google-cloud-bigquery==3.40.1 +google-cloud-storage==3.7.0 +google-cloud-pubsub==2.35.0 diff --git a/logging/samples/snippets/snippets.py b/logging/samples/snippets/snippets.py index 736311e0f4..f6c16d17e3 100644 --- a/logging/samples/snippets/snippets.py +++ b/logging/samples/snippets/snippets.py @@ -90,6 +90,7 @@ def delete_logger(logger_name): if __name__ == "__main__": + parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter ) diff --git a/logging/samples/snippets/snippets_test.py b/logging/samples/snippets/snippets_test.py index 479f742ae5..5cddc92d31 100644 --- a/logging/samples/snippets/snippets_test.py +++ b/logging/samples/snippets/snippets_test.py @@ -23,6 +23,7 @@ TEST_LOGGER_NAME = "example_log_{}".format(uuid.uuid4().hex) +TEST_TEXT = "Hello, world." @pytest.fixture @@ -44,9 +45,18 @@ def eventually_consistent_test(): eventually_consistent_test() -def test_write(): +def test_write(capsys): + snippets.write_entry(TEST_LOGGER_NAME) + @backoff.on_exception(backoff.expo, AssertionError, max_time=120) + def eventually_consistent_test(): + snippets.list_entries(TEST_LOGGER_NAME) + out, _ = capsys.readouterr() + assert TEST_TEXT in out + + eventually_consistent_test() + def test_delete(example_log, capsys): @backoff.on_exception(backoff.expo, NotFound, max_time=120) @@ -54,3 +64,5 @@ def eventually_consistent_test(): snippets.delete_logger(TEST_LOGGER_NAME) out, _ = capsys.readouterr() assert TEST_LOGGER_NAME in out + + eventually_consistent_test() diff --git a/logging/samples/snippets/usage_guide.py b/logging/samples/snippets/usage_guide.py index 6dee33798b..c15fb72afe 100644 --- a/logging/samples/snippets/usage_guide.py +++ b/logging/samples/snippets/usage_guide.py @@ -557,6 +557,7 @@ def main(): except Exception as error: # pylint: disable=broad-except print(" ERROR: %r" % (error,)) for item in to_delete: + pass _backoff_not_found(item.delete)