From 8431da979cffbec6df9c94ee7a10da608a3703aa Mon Sep 17 00:00:00 2001 From: Raissa Ferreira Date: Wed, 9 Jan 2019 18:10:52 -0200 Subject: [PATCH] chore: Bump version to 0.2.1 --- google_cloud_logger/__init__.py | 5 +- setup.py | 13 ++---- .../test_google_cloud_formatter.py | 46 +++++++++++-------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/google_cloud_logger/__init__.py b/google_cloud_logger/__init__.py index 190f6bc..6637e4e 100644 --- a/google_cloud_logger/__init__.py +++ b/google_cloud_logger/__init__.py @@ -19,9 +19,8 @@ def __init__(self, *args, **kwargs): def _get_extra_fields(self, record): if hasattr(record, "extra"): return record.extra - attributes = ( - field for field in record.__dict__.keys() if not inspect.ismethod(field) - ) + attributes = (field for field in record.__dict__.keys() + if not inspect.ismethod(field)) fields = set(attributes).difference(set(self.reserved_attrs.keys())) return {key: getattr(record, key) for key in fields if key} diff --git a/setup.py b/setup.py index 2da469e..9b8282d 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,7 @@ with open("README.md", "r") as output: long_description = output.read() - -__VERSION__ = "0.2.0" +__VERSION__ = "0.2.1" setup( name="google_cloud_logger", @@ -18,15 +17,11 @@ license="MIT", packages=find_packages(), python_requires=">=3.4.*", - install_requires=[ - "python-json-logger>=0.1.10" - ], + install_requires=["python-json-logger>=0.1.10"], classifiers=[ - "Environment :: Web Environment", - "Intended Audience :: Developers", + "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Operating System :: OS Independent", + "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", "Topic :: System :: Logging" ], diff --git a/test/google_cloud_logger/test_google_cloud_formatter.py b/test/google_cloud_logger/test_google_cloud_formatter.py index a0febb3..17e76f8 100644 --- a/test/google_cloud_logger/test_google_cloud_formatter.py +++ b/test/google_cloud_logger/test_google_cloud_formatter.py @@ -3,6 +3,7 @@ import pytest from google_cloud_logger import GoogleCloudFormatter + # from https://stackoverflow.com/a/19258720 class FakeCode(object): def __init__(self, co_filename, co_name): @@ -64,7 +65,9 @@ def record_with_extra_attribute(log_record_factory, mocker): "lineno": "88", "levelname": "WARNING", "message": "farofa", - "extra": {"extra_field": "extra"}, + "extra": { + "extra_field": "extra" + }, } record = log_record_factory(**data) record.getMessage = mocker.Mock(return_value=data["message"]) @@ -95,19 +98,25 @@ def test_add_fields(formatter, record, mocker): mocker.patch.object( formatter, "make_entry", - return_value=OrderedDict( - [ - ("timestamp", "2018-08-30 20:40:57Z"), - ("severity", "WARNING"), - ("message", "farofa"), - ("labels", {"type": "python-application"}), - ("metadata", {"userLabels": {}}), - ( - "sourceLocation", - {"file": "_internal.py", "function": "_log", "line": "88"}, - ), - ] - ), + return_value=OrderedDict([ + ("timestamp", "2018-08-30 20:40:57Z"), + ("severity", "WARNING"), + ("message", "farofa"), + ("labels", { + "type": "python-application" + }), + ("metadata", { + "userLabels": {} + }), + ( + "sourceLocation", + { + "file": "_internal.py", + "function": "_log", + "line": "88" + }, + ), + ]), ) formatter.add_fields(log_record, record, {}) @@ -141,7 +150,8 @@ def test_make_metadata(formatter, record): assert metadata["userLabels"]["extra_field"] == "extra" -def test_make_metadata_with_extra_attribute(formatter, record_with_extra_attribute): +def test_make_metadata_with_extra_attribute(formatter, + record_with_extra_attribute): metadata = formatter.make_metadata(record_with_extra_attribute) assert metadata["userLabels"]["extra_field"] == "extra" @@ -166,10 +176,8 @@ def test_make_source_location(formatter, record): def test_format_timestamp(formatter): - assert ( - formatter.format_timestamp("2018-08-30 20:40:57,245") - == "2018-08-30T20:40:57.245000Z" - ) + assert (formatter.format_timestamp("2018-08-30 20:40:57,245") == + "2018-08-30T20:40:57.245000Z") @pytest.mark.parametrize(