Skip to content

Commit 4189f47

Browse files
chore: format logger_test.py with black (hiero-ledger#1600)
Signed-off-by: GodishalaAshwith <ugs23179_it.ashwith@cbit.org.in>
1 parent cc8c8af commit 4189f47

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
77
## [Unreleased]
88

99
### Tests
10+
- Format tests/unit/logger_test.py with black for code style consistency (#1541)
1011
- Style: formatted `tests/unit/prng_transaction_test.py` with black (#1546)
1112
- Formatted contract unit tests with black for consistent style. (#1523)
1213
- Format account test files with Black (#1519)

tests/unit/logger_test.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
pytestmark = pytest.mark.unit
77

8+
89
def test_set_level():
910
"""Test that changing log level affects what will be logged."""
1011
logger = Logger(LogLevel.DEBUG, "test_logger")
@@ -16,7 +17,7 @@ def test_get_level():
1617
"""Test getting the current log level."""
1718
logger = Logger(level=LogLevel.DEBUG)
1819
assert logger.get_level() == LogLevel.DEBUG
19-
20+
2021
logger.set_level(LogLevel.ERROR)
2122
assert logger.get_level() == LogLevel.ERROR
2223

@@ -25,7 +26,7 @@ def test_logger_creation():
2526
logger = Logger(LogLevel.DEBUG, "test_logger")
2627
assert logger.name == "test_logger"
2728
assert logger.level == LogLevel.DEBUG
28-
29+
2930

3031
def test_logger_creation_from_env():
3132
os.environ["LOG_LEVEL"] = "CRITICAL"
@@ -35,23 +36,23 @@ def test_logger_creation_from_env():
3536

3637
def test_logger_output(capsys):
3738
"""Test that logger outputs the expected messages to stdout.
38-
39+
3940
This test uses pytest's capsys fixture to capture the actual log output,
4041
allowing verification of the exact content written to stdout by the logger.
4142
"""
4243
# Create a logger that logs to the captured stdout with UNIQUE name
4344
logger = Logger(LogLevel.TRACE, "test_logger_output")
44-
45+
4546
# Log messages at different levels with key-value pairs
4647
logger.trace("trace message", "traceKey", "traceValue")
4748
logger.debug("debug message", "debugKey", "debugValue")
4849
logger.info("info message", "infoKey", "infoValue")
4950
logger.warning("warning message", "warningKey", "warningValue")
5051
logger.error("error message", "errorKey", "errorValue")
51-
52+
5253
# Get the captured output
5354
captured = capsys.readouterr()
54-
55+
5556
# Verify that each message appears in the output
5657
assert "trace message: traceKey = traceValue" in captured.out
5758
assert "debug message: debugKey = debugValue" in captured.out
@@ -63,7 +64,7 @@ def test_logger_output(capsys):
6364
logger.error("this should not appear")
6465
captured = capsys.readouterr()
6566
assert captured.out == ""
66-
67+
6768
# Test re-enabling logging
6869
logger.set_silent(False)
6970
logger.info("this should appear")
@@ -73,27 +74,27 @@ def test_logger_output(capsys):
7374

7475
def test_logger_respects_level(capsys):
7576
"""Test that logger only outputs messages at or above its level.
76-
77+
7778
Uses pytest's capsys fixture to verify that log filtering works correctly
7879
by examining which messages actually appear in the captured output based on
7980
the configured log level.
8081
"""
8182
# Create a logger that logs to the captured stdout with UNIQUE name
8283
logger = Logger(LogLevel.INFO, "test_logger_respects_level")
83-
84+
8485
# These should not be logged
8586
logger.trace("trace message")
8687
logger.debug("debug message")
87-
88+
8889
# These should be logged
8990
logger.info("info message")
9091
logger.warning("warning message")
9192
logger.error("error message")
92-
93+
9394
# Get the captured output
9495
captured = capsys.readouterr()
9596
logger.info(captured.out)
96-
97+
9798
# Check that appropriate messages were logged or not logged
9899
assert "trace message" not in captured.out
99100
assert "debug message" not in captured.out

0 commit comments

Comments
 (0)