Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: third_party/psutil/test/_windows.py

Issue 8774018: Add psutil build step to fix pyauto media issues. Upgrade psutil to 0.4.0. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Disable Mac builds. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # $Id: _windows.py 1142 2011-10-05 18:45:49Z g.rodola $ 3 # $Id: _windows.py 1203 2011-10-24 19:10:36Z g.rodola $
4 # 4 #
5 # Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved. 5 # Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
6 # Use of this source code is governed by a BSD-style license that can be 6 # Use of this source code is governed by a BSD-style license that can be
7 # found in the LICENSE file. 7 # found in the LICENSE file.
8 8
9 """Windows specific tests. These are implicitly run by test_psutil.py.""" 9 """Windows specific tests. These are implicitly run by test_psutil.py."""
10 10
11 import os 11 import os
12 import unittest 12 import unittest
13 import platform 13 import platform
14 import signal 14 import signal
15 import time 15 import time
16 import warnings 16 import warnings
17 import atexit 17 import atexit
18 import sys 18 import sys
19 import subprocess
19 20
20 import psutil 21 import psutil
21 import _psutil_mswindows 22 import _psutil_mswindows
22 from test_psutil import reap_children, get_test_subprocess, wait_for_pid 23 from test_psutil import reap_children, get_test_subprocess, wait_for_pid, PY3
23 try: 24 try:
24 import wmi 25 import wmi
25 except ImportError: 26 except ImportError:
26 err = sys.exc_info()[1] 27 err = sys.exc_info()[1]
27 atexit.register(warnings.warn, "Couldn't run wmi tests: %s" % str(err), 28 atexit.register(warnings.warn, "Couldn't run wmi tests: %s" % str(err),
28 RuntimeWarning) 29 RuntimeWarning)
29 wmi = None 30 wmi = None
30 31
31 WIN2000 = platform.win32_ver()[0] == '2000' 32 WIN2000 = platform.win32_ver()[0] == '2000'
32 33
(...skipping 30 matching lines...) Expand all
63 if not platform.uname()[1] in ('vista', 'win-7', 'win7'): 64 if not platform.uname()[1] in ('vista', 'win-7', 'win7'):
64 raise 65 raise
65 else: 66 else:
66 self.assertTrue(rss > 0) 67 self.assertTrue(rss > 0)
67 if not WIN2000: 68 if not WIN2000:
68 self.assertEqual(vms, 0) 69 self.assertEqual(vms, 0)
69 70
70 def test_signal(self): 71 def test_signal(self):
71 p = psutil.Process(self.pid) 72 p = psutil.Process(self.pid)
72 self.assertRaises(ValueError, p.send_signal, signal.SIGINT) 73 self.assertRaises(ValueError, p.send_signal, signal.SIGINT)
74
75 def test_nic_names(self):
76 p = subprocess.Popen(['ipconfig', '/all'], stdout=subprocess.PIPE)
77 out = p.communicate()[0]
78 if PY3:
79 out = str(out, sys.stdout.encoding)
80 nics = psutil.network_io_counters(pernic=True).keys()
81 for nic in nics:
82 if "pseudo-interface" in nic.replace(' ', '-').lower():
83 continue
84 if nic not in out:
85 self.fail("%r nic wasn't found in 'ipconfig /all' output" % nic)
73 86
74 if wmi is not None: 87 if wmi is not None:
75 88
76 # --- Process class tests 89 # --- Process class tests
77 90
78 def test_process_name(self): 91 def test_process_name(self):
79 w = wmi.WMI().Win32_Process(ProcessId=self.pid)[0] 92 w = wmi.WMI().Win32_Process(ProcessId=self.pid)[0]
80 p = psutil.Process(self.pid) 93 p = psutil.Process(self.pid)
81 self.assertEqual(p.name, w.Caption) 94 self.assertEqual(p.name, w.Caption)
82 95
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 break 193 break
181 else: 194 else:
182 self.fail("can't find partition %r", ps_part) 195 self.fail("can't find partition %r", ps_part)
183 196
184 197
185 if __name__ == '__main__': 198 if __name__ == '__main__':
186 test_suite = unittest.TestSuite() 199 test_suite = unittest.TestSuite()
187 test_suite.addTest(unittest.makeSuite(WindowsSpecificTestCase)) 200 test_suite.addTest(unittest.makeSuite(WindowsSpecificTestCase))
188 unittest.TextTestRunner(verbosity=2).run(test_suite) 201 unittest.TextTestRunner(verbosity=2).run(test_suite)
189 202
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698