Merge pull request #19401 from rallytime/test_fixes

Pylint and psutil unit test fixes for 2014.7 branch
This commit is contained in:
Nicole Thomas 2015-01-06 13:24:15 -07:00
commit 83e451d392
3 changed files with 17 additions and 17 deletions

View File

@ -451,7 +451,7 @@ class Compiler(object):
chunk['order'] = cap
if 'name_order' in chunk:
chunk['order'] = chunk['order'] + chunk.pop('name_order') / 10000.0
if chunk['order'] < 0:
if chunk['order'] < 0:
chunk['order'] = cap + 1000000 + chunk['order']
chunks.sort(key=lambda chunk: (chunk['order'], '{0[state]}{0[name]}{0[fun]}'.format(chunk)))
return chunks
@ -1046,7 +1046,7 @@ class State(object):
chunk['order'] = cap
if 'name_order' in chunk:
chunk['order'] = chunk['order'] + chunk.pop('name_order') / 10000.0
if chunk['order'] < 0:
if chunk['order'] < 0:
chunk['order'] = cap + 1000000 + chunk['order']
chunks.sort(key=lambda chunk: (chunk['order'], '{0[state]}{0[name]}{0[fun]}'.format(chunk)))
return chunks

View File

@ -17,25 +17,25 @@ HAS_PSUTIL_VERSION = False
if HAS_PSUTIL:
import psutil
from collections import namedtuple
PSUTIL2 = psutil.version_info >= (2, 0)
STUB_CPU_TIMES = psutil._compat.namedtuple('cputimes', 'user nice system idle')(1, 2, 3, 4)
STUB_VIRT_MEM = psutil._compat.namedtuple('vmem', 'total available percent used free')(1000, 500, 50, 500, 500)
STUB_SWAP_MEM = psutil._compat.namedtuple('swap', 'total used free percent sin sout')(1000, 500, 500, 50, 0, 0)
STUB_PHY_MEM_USAGE = psutil._compat.namedtuple('usage', 'total used free percent')(1000, 500, 500, 50)
STUB_DISK_PARTITION = psutil._compat.namedtuple('partition', 'device mountpoint fstype, opts')('/dev/disk0s2', '/',
'hfs',
'rw,local,rootfs,dovolfs,journaled,multilabel')
STUB_DISK_USAGE = psutil._compat.namedtuple('usage', 'total used free percent')(1000, 500, 500, 50)
STUB_NETWORK_IO = psutil._compat.namedtuple('iostat',
'bytes_sent, bytes_recv, packets_sent, packets_recv, errin errout dropin dropout')(
STUB_CPU_TIMES = namedtuple('cputimes', 'user nice system idle')(1, 2, 3, 4)
STUB_VIRT_MEM = namedtuple('vmem', 'total available percent used free')(1000, 500, 50, 500, 500)
STUB_SWAP_MEM = namedtuple('swap', 'total used free percent sin sout')(1000, 500, 500, 50, 0, 0)
STUB_PHY_MEM_USAGE = namedtuple('usage', 'total used free percent')(1000, 500, 500, 50)
STUB_DISK_PARTITION = namedtuple('partition', 'device mountpoint fstype, opts')('/dev/disk0s2', '/',
'hfs',
'rw,local,rootfs,dovolfs,journaled,multilabel')
STUB_DISK_USAGE = namedtuple('usage', 'total used free percent')(1000, 500, 500, 50)
STUB_NETWORK_IO = namedtuple('iostat',
'bytes_sent, bytes_recv, packets_sent, packets_recv, errin errout dropin dropout')(
1000, 2000, 500, 600, 1, 2, 3, 4)
STUB_DISK_IO = psutil._compat.namedtuple('iostat',
'read_count, write_count, read_bytes, write_bytes, read_time, write_time')(
STUB_DISK_IO = namedtuple('iostat',
'read_count, write_count, read_bytes, write_bytes, read_time, write_time')(
1000, 2000, 500, 600, 2000, 3000)
STUB_USER = psutil._compat.namedtuple('user', 'name, terminal, host, started')('bdobbs', 'ttys000', 'localhost',
0.0)
STUB_USER = namedtuple('user', 'name, terminal, host, started')('bdobbs', 'ttys000', 'localhost', 0.0)
if psutil.version_info >= (0, 6, 0):
HAS_PSUTIL_VERSION = True

View File

@ -186,7 +186,7 @@ class VTTestCase(TestCase):
if buffer_o != expected_data:
self.assertTrue(term.isalive())
# Don't spin
time.sleep(0.1)
time.sleep(0.1)
# term should be dead now
self.assertEqual(buffer_o, expected_data)