Skip to content

Commit fbd9252

Browse files
authored
[Mellanox] Fix test test_setup_logger for mellanox platform
[Mellanox] Fix test test_setup_logger for mellanox platform
1 parent 3621165 commit fbd9252

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

platform/mellanox/mlnx-platform-api/tests/test_dpuctlplat.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ def test_setup_logger(self, dpuctl_obj):
6666
"""Test logger setup"""
6767
# Test with print mode
6868
dpuctl_obj.setup_logger(True)
69-
assert dpuctl_obj.logger_info == print
70-
assert dpuctl_obj.logger_error == print
71-
assert dpuctl_obj.logger_debug == print
69+
# Test that the logger functions add timestamps
70+
with patch('time.strftime') as mock_time:
71+
mock_time.return_value = "2024-01-01 12:00:00"
72+
with patch('builtins.print') as mock_print:
73+
dpuctl_obj.logger_info("test message")
74+
mock_print.assert_called_once_with("[2024-01-01 12:00:00] test message")
7275

7376
# Test with syslogger mode
7477
dpuctl_obj.setup_logger(False)

0 commit comments

Comments
 (0)