Skip to content

Commit c67579a

Browse files
committed
Tests counting newlines only
1 parent c878a85 commit c67579a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

aws_lambda_powertools/logging/formatter.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
1010

1111
from ..shared import constants
12+
from ..shared.functions import strtobool
1213

1314
RESERVED_LOG_ATTRS = (
1415
"name",

tests/functional/test_logger_powertools_formatter.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pytest
1010

1111
from aws_lambda_powertools import Logger
12-
from aws_lambda_powertools.shared import constants
1312

1413

1514
@pytest.fixture
@@ -297,14 +296,16 @@ def test_log_json_indent_compact_indent(stdout, service_name, monkeypatch):
297296
monkeypatch.delenv(name="POWERTOOLS_DEV", raising=False)
298297
logger = Logger(service=service_name, stream=stdout)
299298
logger.info("Test message")
300-
# THEN the json should not be indented using constant.PRETTY_INDENT blank spaces
301-
assert " " * constants.PRETTY_INDENT not in stdout.getvalue()
299+
# THEN the json should not have multiple lines
300+
new_lines = stdout.getvalue().count(os.linesep)
301+
assert new_lines == 1
302302

303303

304304
def test_log_json_pretty_indent(stdout, service_name, monkeypatch):
305305
# GIVEN a logger with default settings and WHEN POWERTOOLS_DEV=="true"
306306
monkeypatch.setenv(name="POWERTOOLS_DEV", value="true")
307307
logger = Logger(service=service_name, stream=stdout)
308308
logger.info("Test message")
309-
# THEN the json should contain indentation (of constant.PRETTY_INDENT blank spaces)
310-
assert " " * constants.PRETTY_INDENT in stdout.getvalue()
309+
# THEN the json should contain more than line
310+
new_lines = stdout.getvalue().count(os.linesep)
311+
assert new_lines > 1

0 commit comments

Comments
 (0)