diff --git a/providers/base/tests/test_camera_quality.py b/providers/base/tests/test_camera_quality.py index 300b59b53..74c586dae 100644 --- a/providers/base/tests/test_camera_quality.py +++ b/providers/base/tests/test_camera_quality.py @@ -23,7 +23,7 @@ from pathlib import Path import time import unittest -from unittest.mock import patch +from unittest.mock import patch, MagicMock import cv2 @@ -38,6 +38,7 @@ @patch("bin.camera_quality_test.TIMEOUT", new=0.05) @patch("bin.camera_quality_test.MIN_INTERVAL", new=0.01) +@patch("builtins.print", new=MagicMock()) class CameraQualityTests(unittest.TestCase): """This class provides test cases for the camera_quality_test module.""" @@ -78,6 +79,7 @@ def test_get_score_from_device(self, mock_score): self.assertEqual(result, 0) mock_score.assert_called_with("video0", True) + @patch("logging.Logger.error", new=MagicMock()) def test_quality_evaluation(self): """ The test should pass if the image is good and fails if it has bad diff --git a/providers/base/tests/test_camera_test.py b/providers/base/tests/test_camera_test.py index de0938ef7..957850966 100644 --- a/providers/base/tests/test_camera_test.py +++ b/providers/base/tests/test_camera_test.py @@ -20,18 +20,15 @@ import unittest import io import sys -from unittest.mock import patch +from unittest.mock import patch, MagicMock from camera_test import CameraTest, v4l2_capability +@patch("builtins.print", new=MagicMock()) class CameraTestTests(unittest.TestCase): """This class provides test cases for the CameraTest class.""" def setUp(self): - # supress stdout to hide print message - suppress_text = io.StringIO() - sys.stdout = suppress_text - self.camera_instance = CameraTest(None) @patch('camera_test.CameraTest._supported_resolutions_to_string') diff --git a/providers/base/tests/test_dkms_info.py b/providers/base/tests/test_dkms_info.py index 30f3ae48e..0b658d245 100644 --- a/providers/base/tests/test_dkms_info.py +++ b/providers/base/tests/test_dkms_info.py @@ -21,10 +21,12 @@ import io import unittest from unittest import mock +from unittest.mock import patch, MagicMock import dkms_info +@patch("logging.Logger.info", new=MagicMock()) class SystemInfoTests(unittest.TestCase): """Tests for System Information Parsing and Collection.""" @@ -118,6 +120,7 @@ def test_match_patterns(self, mock_get_system_modaliases): matched_modalieses) +@patch("logging.Logger.info", new=MagicMock()) class DebianPackageHandlerTest(unittest.TestCase): """Test of DebianPackageHandler.""" diff --git a/providers/base/tests/test_recovery_info.py b/providers/base/tests/test_recovery_info.py index 19658712f..409820954 100644 --- a/providers/base/tests/test_recovery_info.py +++ b/providers/base/tests/test_recovery_info.py @@ -19,7 +19,7 @@ import os import unittest from unittest import mock -from unittest.mock import patch +from unittest.mock import patch, MagicMock import sys import recovery_info @@ -96,6 +96,7 @@ def test_with_of_MountedPartition(self, mock_subprocess_check_output): universal_newlines=True)]) +@patch("builtins.print", new=MagicMock()) class RecoveryInfoTests(unittest.TestCase): """Tests for RecoveryInfo."""