summaryrefslogtreecommitdiff
path: root/psutil/tests
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-03-28 21:21:40 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2018-03-28 21:21:40 +0200
commitbc71d9d3c76ea49963720fc8f7f56f249a99d241 (patch)
tree3cb7a01ed66a2b84d9e20748686148470cd7c058 /psutil/tests
parenta67d6c683c5e134e41aaed6001365dba664896b7 (diff)
downloadpsutil-bc71d9d3c76ea49963720fc8f7f56f249a99d241.tar.gz
return None if cpu_count() is undetermined + add mock test
Diffstat (limited to 'psutil/tests')
-rwxr-xr-xpsutil/tests/test_windows.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py
index 32c46f67..252201c5 100755
--- a/psutil/tests/test_windows.py
+++ b/psutil/tests/test_windows.py
@@ -92,6 +92,14 @@ class TestSystemAPIs(unittest.TestCase):
psutil_value = psutil.cpu_count()
self.assertEqual(sys_value, psutil_value)
+ def test_cpu_count_mocked(self):
+ # Emulate a case where the C extension is unable to determine
+ # CPU count.
+ with mock.patch('psutil._pswindows.cext.cpu_count',
+ return_value=(0, 0)):
+ self.assertIsNone(psutil.cpu_count(logical=True))
+ self.assertIsNone(psutil.cpu_count(logical=False))
+
def test_cpu_freq(self):
w = wmi.WMI()
proc = w.Win32_Processor()[0]