From 820034f7118da99bfff23233f0d17a6473b49c1c Mon Sep 17 00:00:00 2001 From: desbma Date: Fri, 24 Feb 2017 22:09:12 +0100 Subject: [PATCH] Improve hdparm error handling - 2 --- hddfancontrol/__init__.py | 1 - tests/__init__.py | 4 ---- 2 files changed, 5 deletions(-) diff --git a/hddfancontrol/__init__.py b/hddfancontrol/__init__.py index 0c87970..6013da1 100755 --- a/hddfancontrol/__init__.py +++ b/hddfancontrol/__init__.py @@ -97,7 +97,6 @@ class Drive: try: output = subprocess.check_output(cmd, stdin=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, universal_newlines=True) except subprocess.CalledProcessError: supported = False diff --git a/tests/__init__.py b/tests/__init__.py index c567f52..bd44fbe 100755 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -66,28 +66,24 @@ class TestDrive(unittest.TestCase): self.assertEqual(self.drive.supportsHitachiTempQuery(), True) subprocess_check_output_mock.assert_called_once_with(("hdparm", "-H", "/dev/sdz"), stdin=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, universal_newlines=True) with unittest.mock.patch("hddfancontrol.subprocess.check_output") as subprocess_check_output_mock: subprocess_check_output_mock.return_value = "\n/dev/sdz:\nSG_IO: questionable sense data, results may be incorrect\n drive temperature (celsius) is: -18\n drive temperature in range: yes" self.assertEqual(self.drive.supportsHitachiTempQuery(), False) subprocess_check_output_mock.assert_called_once_with(("hdparm", "-H", "/dev/sdz"), stdin=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, universal_newlines=True) with unittest.mock.patch("hddfancontrol.subprocess.check_output") as subprocess_check_output_mock: subprocess_check_output_mock.return_value = "\n/dev/sdz:\nSG_IO: missing sense data, results may be incorrect\n drive temperature (celsius) is: -18\n drive temperature in range: yes" self.assertEqual(self.drive.supportsHitachiTempQuery(), False) subprocess_check_output_mock.assert_called_once_with(("hdparm", "-H", "/dev/sdz"), stdin=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, universal_newlines=True) with unittest.mock.patch("hddfancontrol.subprocess.check_output") as subprocess_check_output_mock: subprocess_check_output_mock.return_value = "\n/dev/sdz:\nSG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 04 51 40 00 21 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n drive temperature (celsius) is: -18\n drive temperature in range: yes" self.assertEqual(self.drive.supportsHitachiTempQuery(), False) subprocess_check_output_mock.assert_called_once_with(("hdparm", "-H", "/dev/sdz"), stdin=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, universal_newlines=True) def test_getState(self):