Skip to content

Commit

Permalink
Redirect logger to stdout in test #2319
Browse files Browse the repository at this point in the history
  • Loading branch information
iamleeg committed Feb 16, 2022
1 parent cdd24fc commit 8fcc726
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion ingestion/functions/common/parsing_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

logger = logging.getLogger(__name__)


try:
with (Path(__file__).parent / "geocoding_countries.json").open() as g:
GEOCODING_COUNTRIES = json.load(g)
Expand Down
7 changes: 7 additions & 0 deletions ingestion/functions/common/parsing_lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import sys
import tempfile
import datetime
import logging

from contextlib import redirect_stdout

from unittest.mock import MagicMock, patch
Expand Down Expand Up @@ -488,6 +490,11 @@ def test_write_to_server_records_input_for_failed_batch_upsert_with_validation_e


with redirect_stdout(io.StringIO()) as f:
# this handler must be set in here for logger to see the redirected stdout
handler = logging.StreamHandler(stream=sys.stdout)
handler.setLevel(logging.DEBUG)
parsing_lib.logger.addHandler(handler)

numCreated, numUpdated, numError = parsing_lib.write_to_server(
iter([_PARSED_CASE]),
"env", _SOURCE_ID, _UPLOAD_ID, {},
Expand Down

0 comments on commit 8fcc726

Please sign in to comment.