From 8227b4cf6a60f3faf4ce965bd5f38056a84d53d6 Mon Sep 17 00:00:00 2001 From: Ramesh Raghupathy Date: Wed, 13 Nov 2024 06:37:57 -0800 Subject: [PATCH] Debugging --- sonic-chassisd/tests/test_chassisd.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sonic-chassisd/tests/test_chassisd.py b/sonic-chassisd/tests/test_chassisd.py index 56438ff66..0ea298a1e 100644 --- a/sonic-chassisd/tests/test_chassisd.py +++ b/sonic-chassisd/tests/test_chassisd.py @@ -437,8 +437,11 @@ def test_is_first_boot_file_found_first_boot(): chassis = MockSmartSwitchChassis() module = "DPU0" + def ss_mock_open(*args, **kwargs): + return open(*args, **kwargs) + with patch("os.path.join", return_value="/mocked/path/to/reboot-cause.txt"), \ - patch("builtins.open", new_callable=mock_open, read_data="First boot") as mock_file: + patch("builtins.open", new_callable=ss_mock_open, read_data="First boot") as mock_file: # Call the method to check if it detects first boot result = chassis._is_first_boot(module) @@ -451,8 +454,11 @@ def test_is_first_boot_file_not_found(): chassis = MockSmartSwitchChassis() module = "DPU0" + def ss_mock_open(*args, **kwargs): + return open(*args, **kwargs) + with patch("os.path.join", return_value="/mocked/path/to/reboot-cause.txt"), \ - patch("builtins.open", new_callable=mock_open) as mock_file: + patch("builtins.open", new_callable=ss_mock_open) as mock_file: # Simulate a file not being found by raising FileNotFoundError mock_file.side_effect = FileNotFoundError