diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py index f344dfebd..55e6731f3 100644 --- a/psutil/tests/test_windows.py +++ b/psutil/tests/test_windows.py @@ -174,14 +174,14 @@ def test_percent_swapmem(self): if (psutil.swap_memory().total > 0): w = wmi.WMI().Win32_PerfRawData_PerfOS_PagingFile( Name="_Total")[0] - # calculate swap usage to integer percent - percentSwap = float(w.PercentUsage) / float(w.PercentUsage_Base) + # calculate swap usage to percent + percentSwap = int(w.PercentUsage) * 100 / int(w.PercentUsage_Base) # exact percent may change but should be reasonable - # assert within +/- 5% and between 0 and 100 - self.assertGreaterEqual(psutil.swap_memory().percent, 0.0) + # assert within +/- 5% and between 0 and 100% + self.assertGreaterEqual(psutil.swap_memory().percent, 0) self.assertAlmostEqual(psutil.swap_memory().percent, percentSwap, - delta=0.05) - self.assertLessEqual(psutil.swap_memory().percent, 1.0) + delta=5) + self.assertLessEqual(psutil.swap_memory().percent, 100) # @unittest.skipIf(wmi is None, "wmi module is not installed") # def test__UPTIME(self):