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")
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"))
def test_tail(): temp_file = create_tempfile() with open(temp_file, 'w') as f: f.write(sample_string1) _, out = get_command_info("cat %s|tail -3" % temp_file) with open(temp_file, 'r') as f: data = f.read() res = tail(3, data) os.remove(temp_file) assert out.rstrip('\n') == '\n'.join(res)
def test_tail(): temp_file = create_tempfile() with open(temp_file, 'w') as f: f.write(sample_string1) _, out = get_command_info("cat %s|tail -3" % temp_file) with open(temp_file, 'r') as f: data = f.read() res = tail(3, data) os.remove(temp_file) eq_(out.rstrip('\n'), '\n'.join(res))
def test_head(): temp_file = create_tempfile() with open(temp_file, 'w') as f: f.write(sample_string1) _, out = get_command_info("cat %s|head -3" % temp_file) with open(temp_file, 'r') as f: data = f.read() res = head(3, data) os.remove(temp_file) eq_(out.rstrip('\n'), '\n'.join(res))