Commit 81405dc6 authored by Phil Dawson's avatar Phil Dawson Committed by Phil Dawson
Browse files

testutils/patch.py: Add methods for applying and removing patches

parent b883a053
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
import subprocess


def apply(file, patch):
    try:
        subprocess.check_output(['patch', file, patch])
    except subprocess.CalledProcessError as e:
        message = "Patch failed with exit code {}\n Output:\n {}".format(
            e.returncode, e.output)
        print(message)
        raise


def remove(file, patch):
    try:
        subprocess.check_output(['patch', '--reverse', file, patch])
    except subprocess.CalledProcessError as e:
        message = "patch --reverse failed with exit code {}\n Output:\n {}".format(
            e.returncode, e.output)
        print(message)
        raise