summaryrefslogtreecommitdiff
path: root/tests/testutils/patch.py
blob: 85b38def848e4389135a38f2c08222630aefc4c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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