示例#1
0
def test_grep_unicode():
    with open(evil_unicode_log, 'wb') as f:
        f.write(invalid_utf8)
    res = grep("11:01", infile=evil_unicode_log)[0]
    os.remove(evil_unicode_log)
    assert res == 'Apr 03 11:01:18 [13042] \ufffdabc'

    res = grep("test_unicode", infile=pacemaker_unicode_log)[0]
    assert res == 'Apr 03 13:37:23 15sp1-1 pacemaker-controld  [1948] (handle_ping)        notice: \\xfc\\xa1\\xa1\\xa1\\xa1\\xa1 test_unicode'
示例#2
0
def test_grep_unicode():
    with open(evil_unicode_log, 'wb') as f:
        f.write(invalid_utf8)
    res = grep("11:01", infile=evil_unicode_log)[0]
    os.remove(evil_unicode_log)
    eq_(res, 'Apr 03 11:01:18 [13042] \ufffdabc')

    res = grep("test_unicode", infile=pacemaker_unicode_log)[0]
    eq_(res, 'Apr 03 13:37:23 15sp1-1 pacemaker-controld  [1948] (handle_ping)        notice: \\xfc\\xa1\\xa1\\xa1\\xa1\\xa1 test_unicode')
示例#3
0
def test_grep():
    res = grep("^Name", incmd="rpm -qi bash")[0]
    _, out = get_command_info("rpm -qi bash|grep \"^Name\"")
    eq_(res, out.strip("\n"))

    in_string = """aaaa
bbbb
"""
    temp_file = create_tempfile()
    with open(temp_file, 'w') as f:
        f.write(in_string)
    res = grep("aaaa", infile=temp_file, flag='v')[0]
    _, out = get_command_info("grep -v aaaa %s"%temp_file)
    os.remove(temp_file)
    eq_(res, out.strip("\n"))
示例#4
0
def test_grep():
    res = grep("^Name", incmd="rpm -qi bash")[0]
    _, out = get_command_info("rpm -qi bash|grep \"^Name\"")
    assert res == out.strip("\n")

    in_string = """aaaa
bbbb
"""
    temp_file = create_tempfile()
    with open(temp_file, 'w') as f:
        f.write(in_string)
    res = grep("aaaa", infile=temp_file, flag='v')[0]
    _, out = get_command_info("grep -v aaaa %s" % temp_file)
    os.remove(temp_file)
    assert res == out.strip("\n")