Skip to content

Instantly share code, notes, and snippets.

@wiggin15
Created September 5, 2015 11:00
Show Gist options
  • Save wiggin15/ae62963b33716da3a503 to your computer and use it in GitHub Desktop.
Save wiggin15/ae62963b33716da3a503 to your computer and use it in GitHub Desktop.
psutil #610 test output
root@host-ci20 (Solaris 10) ➜ psutil py.test
================================================================================ test session starts ================================================================================
platform sunos5 -- Python 2.7.8 -- py-1.4.30 -- pytest-2.7.2
rootdir: /root/psutil, inifile:
collected 260 items
test/test_memory_leaks.py ..ss.....sss.......s...sss....s..ss.....sss.......s...sss....s......s...F.ss..
test/test_psutil.py ..F.......F..........................sF.s..........ss.........s......Fsssss................................................................................F.....................F.FF.
===================================================================================== FAILURES ======================================================================================
___________________________________________________________________ TestModuleFunctionsLeaks.test_net_io_counters ___________________________________________________________________
self = <test_memory_leaks.TestModuleFunctionsLeaks testMethod=test_net_io_counters>
@skip_if_linux()
def test_net_io_counters(self):
> self.execute('net_io_counters')
test/test_memory_leaks.py:407:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/test_memory_leaks.py:57: in execute
self.call(function, *args, **kwargs)
test/test_memory_leaks.py:359: in call
fun(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pernic = False
def net_io_counters(pernic=False):
"""Return network I/O statistics as a namedtuple including
the following fields:
- bytes_sent: number of bytes sent
- bytes_recv: number of bytes received
- packets_sent: number of packets sent
- packets_recv: number of packets received
- errin: total number of errors while receiving
- errout: total number of errors while sending
- dropin: total number of incoming packets which were dropped
- dropout: total number of outgoing packets which were dropped
(always 0 on OSX and BSD)
If pernic is True return the same information for every
network interface installed on the system as a dictionary
with network interface names as the keys and the namedtuple
described above as the values.
"""
rawdict = _psplatform.net_io_counters()
if not rawdict:
> raise RuntimeError("couldn't find any network interface")
E RuntimeError: couldn't find any network interface
../python/lib64/python2.7/site-packages/psutil-3.2.1-py2.7-solaris-2.10-i86pc.64bit.egg/psutil/__init__.py:1718: RuntimeError
___________________________________________________________________________ TestSystemAPIs.test_cpu_count ___________________________________________________________________________
self = <test_psutil.TestSystemAPIs testMethod=test_cpu_count>
def test_cpu_count(self):
logical = psutil.cpu_count()
self.assertEqual(logical, len(psutil.cpu_times(percpu=True)))
self.assertGreaterEqual(logical, 1)
#
if os.path.exists("/proc/cpuinfo"):
with open("/proc/cpuinfo") as fd:
cpuinfo_data = fd.read()
if "physical id" not in cpuinfo_data:
raise unittest.SkipTest("cpuinfo doesn't include physical id")
> physical = psutil.cpu_count(logical=False)
E TypeError: cpu_count_physical() takes no arguments (1 given)
test/test_psutil.py:763: TypeError
________________________________________________________________________ TestSystemAPIs.test_net_io_counters ________________________________________________________________________
self = <test_psutil.TestSystemAPIs testMethod=test_net_io_counters>
def test_net_io_counters(self):
def check_ntuple(nt):
self.assertEqual(nt[0], nt.bytes_sent)
self.assertEqual(nt[1], nt.bytes_recv)
self.assertEqual(nt[2], nt.packets_sent)
self.assertEqual(nt[3], nt.packets_recv)
self.assertEqual(nt[4], nt.errin)
self.assertEqual(nt[5], nt.errout)
self.assertEqual(nt[6], nt.dropin)
self.assertEqual(nt[7], nt.dropout)
assert nt.bytes_sent >= 0, nt
assert nt.bytes_recv >= 0, nt
assert nt.packets_sent >= 0, nt
assert nt.packets_recv >= 0, nt
assert nt.errin >= 0, nt
assert nt.errout >= 0, nt
assert nt.dropin >= 0, nt
assert nt.dropout >= 0, nt
> ret = psutil.net_io_counters(pernic=False)
test/test_psutil.py:1047:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pernic = False
def net_io_counters(pernic=False):
"""Return network I/O statistics as a namedtuple including
the following fields:
- bytes_sent: number of bytes sent
- bytes_recv: number of bytes received
- packets_sent: number of packets sent
- packets_recv: number of packets received
- errin: total number of errors while receiving
- errout: total number of errors while sending
- dropin: total number of incoming packets which were dropped
- dropout: total number of outgoing packets which were dropped
(always 0 on OSX and BSD)
If pernic is True return the same information for every
network interface installed on the system as a dictionary
with network interface names as the keys and the namedtuple
described above as the values.
"""
rawdict = _psplatform.net_io_counters()
if not rawdict:
> raise RuntimeError("couldn't find any network interface")
E RuntimeError: couldn't find any network interface
../python/lib64/python2.7/site-packages/psutil-3.2.1-py2.7-solaris-2.10-i86pc.64bit.egg/psutil/__init__.py:1718: RuntimeError
___________________________________________________________________________ TestProcess.test_connections ____________________________________________________________________________
args = (<test_psutil.TestProcess testMethod=test_connections>,), kwargs = {}
@functools.wraps(fun)
def wrapper(*args, **kwargs):
try:
> return fun(*args, **kwargs)
test/test_psutil.py:472:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/test_psutil.py:2020: in test_connections
self.assertEqual(len(cons), 1)
E AssertionError: 0 != 1
________________________________________________________________________ TestProcess.test_prog_w_funky_name _________________________________________________________________________
self = <test_psutil.TestProcess testMethod=test_prog_w_funky_name>
@unittest.skipUnless(POSIX, "posix only")
# TODO: add support for other compilers
@unittest.skipUnless(which("gcc"), "gcc not available")
def test_prog_w_funky_name(self):
# Test that name(), exe() and cmdline() correctly handle programs
# with funky chars such as spaces and ")", see:
# https://github.com/giampaolo/psutil/issues/628
# funky_path = os.path.join(tempfile.gettempdir(), "foo bar )")
if OSX:
tmpdir = "/private/tmp"
else:
tmpdir = "/tmp"
fd, funky_path = tempfile.mkstemp(
prefix='psutil-', suffix='foo bar )', dir=tmpdir)
os.close(fd)
fd, c_file = tempfile.mkstemp(
prefix='psutil-', suffix='.c', dir=tmpdir)
os.close(fd)
self.addCleanup(safe_remove, c_file)
self.addCleanup(safe_remove, funky_path)
with open(c_file, "w") as f:
f.write("void main() { pause(); }")
subprocess.check_call(["gcc", c_file, "-o", funky_path])
sproc = get_test_subprocess(
[funky_path, "arg1", "arg2", "", "arg3", ""])
p = psutil.Process(sproc.pid)
# ...in order to try to prevent occasional failures on travis
wait_for_pid(p.pid)
> self.assertEqual(p.name(), os.path.basename(funky_path))
E AssertionError: 'psutil-kD3zplfoo' != 'psutil-kD3zplfoo bar )'
test/test_psutil.py:1743: AssertionError
____________________________________________________________________________ TestMisc.test_serialization ____________________________________________________________________________
self = <test_psutil.TestMisc testMethod=test_serialization>
def test_serialization(self):
def check(ret):
if json is not None:
json.loads(json.dumps(ret))
a = pickle.dumps(ret)
b = pickle.loads(a)
self.assertEqual(ret, b)
check(psutil.Process().as_dict())
check(psutil.virtual_memory())
check(psutil.swap_memory())
check(psutil.cpu_times())
check(psutil.cpu_times_percent(interval=0))
> check(psutil.net_io_counters())
test/test_psutil.py:2957:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pernic = False
def net_io_counters(pernic=False):
"""Return network I/O statistics as a namedtuple including
the following fields:
- bytes_sent: number of bytes sent
- bytes_recv: number of bytes received
- packets_sent: number of packets sent
- packets_recv: number of packets received
- errin: total number of errors while receiving
- errout: total number of errors while sending
- dropin: total number of incoming packets which were dropped
- dropout: total number of outgoing packets which were dropped
(always 0 on OSX and BSD)
If pernic is True return the same information for every
network interface installed on the system as a dictionary
with network interface names as the keys and the namedtuple
described above as the values.
"""
rawdict = _psplatform.net_io_counters()
if not rawdict:
> raise RuntimeError("couldn't find any network interface")
E RuntimeError: couldn't find any network interface
../python/lib64/python2.7/site-packages/psutil-3.2.1-py2.7-solaris-2.10-i86pc.64bit.egg/psutil/__init__.py:1718: RuntimeError
___________________________________________________________________________ TestUnicode.test_proc_cmdline ___________________________________________________________________________
self = <test_psutil.TestUnicode testMethod=test_proc_cmdline>
def test_proc_cmdline(self):
subp = get_test_subprocess(cmd=[self.uexe])
p = psutil.Process(subp.pid)
self.assertIsInstance("".join(p.cmdline()), str)
> self.assertEqual(p.cmdline(), [self.uexe])
E AssertionError: Lists differ: [''] != ['/tmp/psutil-\xc3\xa8.exe']
E
E First differing element 0:
E
E /tmp/psutil-è.exe
E
E - ['']
E + ['/tmp/psutil-\xc3\xa8.exe']
test/test_psutil.py:3136: AssertionError
_____________________________________________________________________________ TestUnicode.test_proc_exe _____________________________________________________________________________
self = <test_psutil.TestUnicode testMethod=test_proc_exe>
def test_proc_exe(self):
subp = get_test_subprocess(cmd=[self.uexe])
p = psutil.Process(subp.pid)
self.assertIsInstance(p.name(), str)
> self.assertEqual(os.path.basename(p.name()), "psutil-è.exe")
E AssertionError: '' != 'psutil-\xc3\xa8.exe'
test/test_psutil.py:3121: AssertionError
____________________________________________________________________________ TestUnicode.test_proc_name _____________________________________________________________________________
self = <test_psutil.TestUnicode testMethod=test_proc_name>
def test_proc_name(self):
subp = get_test_subprocess(cmd=[self.uexe])
if WINDOWS:
from psutil._pswindows import py2_strencode
name = py2_strencode(psutil._psplatform.cext.proc_name(subp.pid))
else:
name = psutil.Process(subp.pid).name()
> self.assertEqual(name, "psutil-è.exe")
E AssertionError: '' != 'psutil-\xc3\xa8.exe'
test/test_psutil.py:3130: AssertionError
================================================================= 9 failed, 218 passed, 33 skipped in 60.65 seconds =================================================================
root@host-ci20 (Solaris 10) ➜ psutil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment