How to apply a git patch from one repository to another?

If manually editing the patch file is out of the question or infeasible, this can be done with standard options (available in git apply, git format-patch and GNU patch). -p<n> removes n leading directories from the paths in the patch. After processing -p, –directory=<root> prepends root to each of the paths in the patch before … Read more

What does “1 line adds whitespace errors” mean when applying a patch?

You don’t need to care. The warning enacts a standard of cleanliness of text files in regard to whitespace, the kind of thing that many programmers tend to care about. As the manual explains: What are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including lines that solely consist of whitespaces) … Read more

Using python’s mock patch.object to change the return value of a method called within another method

There are two ways you can do this; with patch and with patch.object Patch assumes that you are not directly importing the object but that it is being used by the object you are testing as in the following #foo.py def some_fn(): return ‘some_fn’ class Foo(object): def method_1(self): return some_fn() #bar.py import foo class Bar(object): … Read more