示例#1
0
def test_combiner_api():
    ps_auxcww = PsAuxcww(context_wrap(PS_AUXCWW_LINES))
    ps = Ps(None, None, None, None, ps_auxcww, None, None)
    assert ps.pids == [1, 2, 3, 8, 9, 11]
    assert len(ps.processes) == 6
    assert ps.processes[0]
    assert 'systemd' in ps.commands
    assert len(ps.search(USER='******')) == 6
    assert 'systemd' in ps
    assert ps[1] == {
        '%CPU': 0.1,
        '%MEM': 0.0,
        'ARGS': '',
        'COMMAND': 'systemd',
        'COMMAND_NAME': 'systemd',
        'F': None,
        'NI': None,
        'PID': 1,
        'PPID': None,
        'PRI': None,
        'RSS': 7756.0,
        'START': '2019',
        'STAT': 'Ss',
        'TIME': '477:10',
        'TTY': '?',
        'UID': None,
        'USER': '******',
        'VSZ': 195712.0,
        'WCHAN': None
    }
    assert ps[1000] is None
    assert [proc for proc in ps]
示例#2
0
def test_search_ps_alxwww_w_grep():
    p = PsAlxwww(context_wrap(PS_ALXWWW_W_GREP))
    ps = Ps(p, None, None, None, None, None, None)
    assert len(ps.search(COMMAND_NAME__contains='dbus')) == 1