dstandish commented on code in PR #26973:
URL: https://github.com/apache/airflow/pull/26973#discussion_r991496566
##########
tests/providers/google/cloud/utils/test_credentials_provider.py:
##########
@@ -327,11 +327,28 @@ def
test_get_credentials_and_project_id_with_mutually_exclusive_configuration(
'google.oauth2.service_account.Credentials.from_service_account_file',
)
def test_disable_logging(self, mock_default, mock_info, mock_file):
- # assert not logs
+ """
+ Test disable logging in ``get_credentials_and_project_id``.
+
+ Due to selected limitation:
+ - Unable mixin pytest autouse-fixture `caplog` with `unittest.TestCase`
+ - `unittest.TestCase.assertNoLogs` available only in Python 3.10+
+
+ We use some workarounds for filtering specific logger and raise error
with these records.
+ """
+ logger_name =
"airflow.providers.google.cloud.utils.credentials_provider._CredentialProvider"
+
Review Comment:
small nitty suggestion.... move this line below function def so it's closer
to where it's used / easier to see and find
##########
tests/providers/google/cloud/utils/test_credentials_provider.py:
##########
@@ -327,11 +327,28 @@ def
test_get_credentials_and_project_id_with_mutually_exclusive_configuration(
'google.oauth2.service_account.Credentials.from_service_account_file',
)
def test_disable_logging(self, mock_default, mock_info, mock_file):
- # assert not logs
+ """
+ Test disable logging in ``get_credentials_and_project_id``.
+
+ Due to selected limitation:
+ - Unable mixin pytest autouse-fixture `caplog` with `unittest.TestCase`
+ - `unittest.TestCase.assertNoLogs` available only in Python 3.10+
+
+ We use some workarounds for filtering specific logger and raise error
with these records.
+ """
+ logger_name =
"airflow.providers.google.cloud.utils.credentials_provider._CredentialProvider"
+
+ def assert_no_logs(records, name):
+ records = [log_record for log_record in records if log_record.name
== name]
+ if not records:
+ return
+ raise AssertionError(f"Not expected get any log message from
logger={name!r}, got: {records}")
Review Comment:
```suggestion
raise AssertionError(f"Did not expect any log message from
logger={name!r}, but got: {records}")
```
##########
tests/providers/google/cloud/utils/test_credentials_provider.py:
##########
@@ -327,11 +327,28 @@ def
test_get_credentials_and_project_id_with_mutually_exclusive_configuration(
'google.oauth2.service_account.Credentials.from_service_account_file',
)
def test_disable_logging(self, mock_default, mock_info, mock_file):
- # assert not logs
+ """
+ Test disable logging in ``get_credentials_and_project_id``.
+
+ Due to selected limitation:
+ - Unable mixin pytest autouse-fixture `caplog` with `unittest.TestCase`
+ - `unittest.TestCase.assertNoLogs` available only in Python 3.10+
+
+ We use some workarounds for filtering specific logger and raise error
with these records.
Review Comment:
```suggestion
Due to following limitations, we use some workarounds for filtering
specific logger and raise error with these records:
- Cannot use pytest autouse-fixture `caplog` with `unittest.TestCase`
- `unittest.TestCase.assertNoLogs` available only in Python 3.10+
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]