summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-02 04:43:47 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-02 04:43:47 +0200
commit4e0a55b12666e0fd3d3fb14b5c5e32bc3c7bde55 (patch)
tree61df77286c2809b0e6b8cba8a4737542e3309442
parent3681cd7b4a404ad15c5117c78123bd0cdbb462e1 (diff)
parentb47f72620fe547e53ff7ab1247509d07b586e39f (diff)
downloadpsutil-4e0a55b12666e0fd3d3fb14b5c5e32bc3c7bde55.tar.gz
Merge branch 'master' into 1040-fix-unicode
-rw-r--r--CREDITS19
-rwxr-xr-xpsutil/tests/test_connections.py3
-rwxr-xr-xpsutil/tests/test_windows.py40
-rwxr-xr-xscripts/internal/winmake.py7
4 files changed, 46 insertions, 23 deletions
diff --git a/CREDITS b/CREDITS
index 32d3d51c..148c7bbc 100644
--- a/CREDITS
+++ b/CREDITS
@@ -20,6 +20,25 @@ C: Italy
E: g.rodola@gmail.com
W: http://grodola.blogspot.com/
+Experts
+=======
+
+Github usernames of people to CC on github when in need of help.
+
+- NetBSD:
+ - 0-wiz-0, Thomas Klausner
+ - ryoqun, Ryo Onodera
+- OpenBSD:
+ - landryb, Landry Breuil
+- OSX:
+ - whitlockjc, Jeremy Whitlock
+- Windows:
+ - mrjefftang, Jeff Tang
+ - wj32, Wen Jia Liu
+ - fbenkstein, Frank Benkstein
+- SunOS:
+ - wiggin15, Arnon Yaari
+
Contributors
============
diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py
index c47160c7..d0c5445a 100755
--- a/psutil/tests/test_connections.py
+++ b/psutil/tests/test_connections.py
@@ -74,8 +74,9 @@ class Base(object):
# so there may be more connections.
return smap[sock.fileno()]
else:
- self.assertEqual(smap[sock.fileno()].fd, sock.fileno())
self.assertEqual(len(cons), 1)
+ if cons[0].fd != -1:
+ self.assertEqual(smap[sock.fileno()].fd, sock.fileno())
return cons[0]
def check_socket(self, sock, conn=None):
diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py
index 77647652..2a883132 100755
--- a/psutil/tests/test_windows.py
+++ b/psutil/tests/test_windows.py
@@ -33,7 +33,6 @@ from psutil._compat import callable
from psutil.tests import APPVEYOR
from psutil.tests import get_test_subprocess
from psutil.tests import HAS_BATTERY
-from psutil.tests import HAS_SENSORS_BATTERY
from psutil.tests import mock
from psutil.tests import reap_children
from psutil.tests import retry_before_failing
@@ -190,33 +189,30 @@ class TestSystemAPIs(unittest.TestCase):
@unittest.skipIf(not WINDOWS, "WINDOWS only")
class TestSensorsBattery(unittest.TestCase):
- @unittest.skipIf(not HAS_SENSORS_BATTERY, "not supported")
+ def test_has_battery(self):
+ if win32api.GetPwrCapabilities()['SystemBatteriesPresent']:
+ self.assertIsNotNone(psutil.sensors_battery())
+ else:
+ self.assertIsNone(psutil.sensors_battery())
+
@unittest.skipIf(not HAS_BATTERY, "no battery")
def test_percent(self):
w = wmi.WMI()
+ battery_wmi = w.query('select * from Win32_Battery')[0]
battery_psutil = psutil.sensors_battery()
- if battery_psutil is None:
- with self.assertRaises(IndexError):
- w.query('select * from Win32_Battery')[0]
- else:
- battery_wmi = w.query('select * from Win32_Battery')[0]
- if battery_psutil is None:
- self.assertNot(battery_wmi.EstimatedChargeRemaining)
- return
-
- self.assertAlmostEqual(
- battery_psutil.percent, battery_wmi.EstimatedChargeRemaining,
- delta=1)
- self.assertEqual(
- battery_psutil.power_plugged, battery_wmi.BatteryStatus == 1)
+ self.assertAlmostEqual(
+ battery_psutil.percent, battery_wmi.EstimatedChargeRemaining,
+ delta=1)
- @unittest.skipIf(not HAS_SENSORS_BATTERY, "not supported")
@unittest.skipIf(not HAS_BATTERY, "no battery")
- def test_battery_present(self):
- if win32api.GetPwrCapabilities()['SystemBatteriesPresent']:
- self.assertIsNotNone(psutil.sensors_battery())
- else:
- self.assertIsNone(psutil.sensors_battery())
+ def test_power_plugged(self):
+ w = wmi.WMI()
+ battery_wmi = w.query('select * from Win32_Battery')[0]
+ battery_psutil = psutil.sensors_battery()
+ # Status codes:
+ # https://msdn.microsoft.com/en-us/library/aa394074(v=vs.85).aspx
+ self.assertEqual(battery_psutil.power_plugged,
+ battery_wmi.BatteryStatus == 2)
def test_emulate_no_battery(self):
with mock.patch("psutil._pswindows.cext.sensors_battery",
diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py
index c9139977..7b70404a 100755
--- a/scripts/internal/winmake.py
+++ b/scripts/internal/winmake.py
@@ -354,6 +354,13 @@ def test_unicode():
@cmd
+def test_connections():
+ """Run connections tests"""
+ install()
+ sh("%s -m unittest -v psutil.tests.test_connections" % PYTHON)
+
+
+@cmd
def test_contracts():
"""Run contracts tests"""
install()