Skip to content

Commit

Permalink
Put unit test back to percent
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Oct 22, 2022
1 parent 0fa7c0e commit c2460e0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions psutil/tests/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c2460e0

Please sign in to comment.