prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Unit test recipes (reportlab to begin with)
  The test suite is currently running full integration tests for a bunch of recipes.
  While integration tests are good, we cannot currently use them for all recipes because they run for too long.
  However having unit tests for all recipes should be feasible and may still cover some issues like https://github.com/kivy/python-for-android/pull/1357#issuecomment-423614116.
  Unit tests were recently enabled the following pull request https://github.com/kivy/python-for-android/pull/1379. So the idea is to increase the coverage start from reportlab recipe as a use case.
  
  </issue>
  <code>
  [start of pythonforandroid/recipes/reportlab/__init__.py]
  1 import os, sh
  2 from pythonforandroid.recipe import CompiledComponentsPythonRecipe
  3 from pythonforandroid.util import (current_directory, ensure_dir)
  4 from pythonforandroid.logger import (info, shprint)
  5 
  6 
  7 class ReportLabRecipe(CompiledComponentsPythonRecipe):
  8     version = 'c088826211ca'
  9     url = 'https://bitbucket.org/rptlab/reportlab/get/{version}.tar.gz'
  10     depends = [('python2', 'python3crystax'), 'freetype']
  11 
  12     def prebuild_arch(self, arch):
  13         if not self.is_patched(arch):
  14             super(ReportLabRecipe, self).prebuild_arch(arch)
  15             self.apply_patch('patches/fix-setup.patch', arch.arch)
  16             recipe_dir = self.get_build_dir(arch.arch)
  17             shprint(sh.touch, os.path.join(recipe_dir, '.patched'))
  18             ft = self.get_recipe('freetype', self.ctx)
  19             ft_dir = ft.get_build_dir(arch.arch)
  20             ft_lib_dir = os.environ.get('_FT_LIB_', os.path.join(ft_dir, 'objs', '.libs'))
  21             ft_inc_dir = os.environ.get('_FT_INC_', os.path.join(ft_dir, 'include'))
  22             tmp_dir = os.path.normpath(os.path.join(recipe_dir, "..", "..", "tmp"))
  23             info('reportlab recipe: recipe_dir={}'.format(recipe_dir))
  24             info('reportlab recipe: tmp_dir={}'.format(tmp_dir))
  25             info('reportlab recipe: ft_dir={}'.format(ft_dir))
  26             info('reportlab recipe: ft_lib_dir={}'.format(ft_lib_dir))
  27             info('reportlab recipe: ft_inc_dir={}'.format(ft_inc_dir))
  28             with current_directory(recipe_dir):
  29                 sh.ls('-lathr')
  30                 ensure_dir(tmp_dir)
  31                 pfbfile = os.path.join(tmp_dir, "pfbfer-20070710.zip")
  32                 if not os.path.isfile(pfbfile):
  33                     sh.wget("http://www.reportlab.com/ftp/pfbfer-20070710.zip", "-O", pfbfile)
  34                 sh.unzip("-u", "-d", os.path.join(recipe_dir, "src", "reportlab", "fonts"), pfbfile)
  35                 if os.path.isfile("setup.py"):
  36                     with open('setup.py', 'rb') as f:
  37                         text = f.read().replace('_FT_LIB_', ft_lib_dir).replace('_FT_INC_', ft_inc_dir)
  38                     with open('setup.py', 'wb') as f:
  39                         f.write(text)
  40 
  41 
  42 recipe = ReportLabRecipe()
  43
  [end of pythonforandroid/recipes/reportlab/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pythonforandroid/recipes/reportlab/__init__.py b/pythonforandroid/recipes/reportlab/__init__.py
  --- a/pythonforandroid/recipes/reportlab/__init__.py
  +++ b/pythonforandroid/recipes/reportlab/__init__.py
  @@ -26,16 +26,15 @@
               info('reportlab recipe: ft_lib_dir={}'.format(ft_lib_dir))
               info('reportlab recipe: ft_inc_dir={}'.format(ft_inc_dir))
               with current_directory(recipe_dir):
  -                sh.ls('-lathr')
                   ensure_dir(tmp_dir)
                   pfbfile = os.path.join(tmp_dir, "pfbfer-20070710.zip")
                   if not os.path.isfile(pfbfile):
                       sh.wget("http://www.reportlab.com/ftp/pfbfer-20070710.zip", "-O", pfbfile)
                   sh.unzip("-u", "-d", os.path.join(recipe_dir, "src", "reportlab", "fonts"), pfbfile)
                   if os.path.isfile("setup.py"):
  -                    with open('setup.py', 'rb') as f:
  +                    with open('setup.py', 'r') as f:
                           text = f.read().replace('_FT_LIB_', ft_lib_dir).replace('_FT_INC_', ft_inc_dir)
  -                    with open('setup.py', 'wb') as f:
  +                    with open('setup.py', 'w') as f:
                           f.write(text)
  
verification_info: {"golden_diff": "diff --git a/pythonforandroid/recipes/reportlab/__init__.py b/pythonforandroid/recipes/reportlab/__init__.py\n--- a/pythonforandroid/recipes/reportlab/__init__.py\n+++ b/pythonforandroid/recipes/reportlab/__init__.py\n@@ -26,16 +26,15 @@\n             info('reportlab recipe: ft_lib_dir={}'.format(ft_lib_dir))\n             info('reportlab recipe: ft_inc_dir={}'.format(ft_inc_dir))\n             with current_directory(recipe_dir):\n-                sh.ls('-lathr')\n                 ensure_dir(tmp_dir)\n                 pfbfile = os.path.join(tmp_dir, \"pfbfer-20070710.zip\")\n                 if not os.path.isfile(pfbfile):\n                     sh.wget(\"http://www.reportlab.com/ftp/pfbfer-20070710.zip\", \"-O\", pfbfile)\n                 sh.unzip(\"-u\", \"-d\", os.path.join(recipe_dir, \"src\", \"reportlab\", \"fonts\"), pfbfile)\n                 if os.path.isfile(\"setup.py\"):\n-                    with open('setup.py', 'rb') as f:\n+                    with open('setup.py', 'r') as f:\n                         text = f.read().replace('_FT_LIB_', ft_lib_dir).replace('_FT_INC_', ft_inc_dir)\n-                    with open('setup.py', 'wb') as f:\n+                    with open('setup.py', 'w') as f:\n                         f.write(text)\n", "issue": "Unit test recipes (reportlab to begin with)\nThe test suite is currently running full integration tests for a bunch of recipes.\r\nWhile integration tests are good, we cannot currently use them for all recipes because they run for too long.\r\nHowever having unit tests for all recipes should be feasible and may still cover some issues like https://github.com/kivy/python-for-android/pull/1357#issuecomment-423614116.\r\nUnit tests were recently enabled the following pull request https://github.com/kivy/python-for-android/pull/1379. So the idea is to increase the coverage start from reportlab recipe as a use case.\n", "before_files": [{"content": "import os, sh\nfrom pythonforandroid.recipe import CompiledComponentsPythonRecipe\nfrom pythonforandroid.util import (current_directory, ensure_dir)\nfrom pythonforandroid.logger import (info, shprint)\n\n\nclass ReportLabRecipe(CompiledComponentsPythonRecipe):\n    version = 'c088826211ca'\n    url = 'https://bitbucket.org/rptlab/reportlab/get/{version}.tar.gz'\n    depends = [('python2', 'python3crystax'), 'freetype']\n\n    def prebuild_arch(self, arch):\n        if not self.is_patched(arch):\n            super(ReportLabRecipe, self).prebuild_arch(arch)\n            self.apply_patch('patches/fix-setup.patch', arch.arch)\n            recipe_dir = self.get_build_dir(arch.arch)\n            shprint(sh.touch, os.path.join(recipe_dir, '.patched'))\n            ft = self.get_recipe('freetype', self.ctx)\n            ft_dir = ft.get_build_dir(arch.arch)\n            ft_lib_dir = os.environ.get('_FT_LIB_', os.path.join(ft_dir, 'objs', '.libs'))\n            ft_inc_dir = os.environ.get('_FT_INC_', os.path.join(ft_dir, 'include'))\n            tmp_dir = os.path.normpath(os.path.join(recipe_dir, \"..\", \"..\", \"tmp\"))\n            info('reportlab recipe: recipe_dir={}'.format(recipe_dir))\n            info('reportlab recipe: tmp_dir={}'.format(tmp_dir))\n            info('reportlab recipe: ft_dir={}'.format(ft_dir))\n            info('reportlab recipe: ft_lib_dir={}'.format(ft_lib_dir))\n            info('reportlab recipe: ft_inc_dir={}'.format(ft_inc_dir))\n            with current_directory(recipe_dir):\n                sh.ls('-lathr')\n                ensure_dir(tmp_dir)\n                pfbfile = os.path.join(tmp_dir, \"pfbfer-20070710.zip\")\n                if not os.path.isfile(pfbfile):\n                    sh.wget(\"http://www.reportlab.com/ftp/pfbfer-20070710.zip\", \"-O\", pfbfile)\n                sh.unzip(\"-u\", \"-d\", os.path.join(recipe_dir, \"src\", \"reportlab\", \"fonts\"), pfbfile)\n                if os.path.isfile(\"setup.py\"):\n                    with open('setup.py', 'rb') as f:\n                        text = f.read().replace('_FT_LIB_', ft_lib_dir).replace('_FT_INC_', ft_inc_dir)\n                    with open('setup.py', 'wb') as f:\n                        f.write(text)\n\n\nrecipe = ReportLabRecipe()\n", "path": "pythonforandroid/recipes/reportlab/__init__.py"}]}