prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Tests missing for `User.mention_markdown` and `User.mention_html`
  And while we're at it. Maybe `helpers.mention_markdown/html` too.
  
  
  </issue>
  <code>
  [start of telegram/utils/helpers.py]
  1 #!/usr/bin/env python
  2 #
  3 # A library that provides a Python interface to the Telegram Bot API
  4 # Copyright (C) 2015-2018
  5 # Leandro Toledo de Souza <devs@python-telegram-bot.org>
  6 #
  7 # This program is free software: you can redistribute it and/or modify
  8 # it under the terms of the GNU Lesser Public License as published by
  9 # the Free Software Foundation, either version 3 of the License, or
  10 # (at your option) any later version.
  11 #
  12 # This program is distributed in the hope that it will be useful,
  13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15 # GNU Lesser Public License for more details.
  16 #
  17 # You should have received a copy of the GNU Lesser Public License
  18 # along with this program.  If not, see [http://www.gnu.org/licenses/].
  19 """This module contains helper functions."""
  20 from html import escape
  21 
  22 import re
  23 import signal
  24 from datetime import datetime
  25 
  26 # From https://stackoverflow.com/questions/2549939/get-signal-names-from-numbers-in-python
  27 _signames = {v: k
  28              for k, v in reversed(sorted(vars(signal).items()))
  29              if k.startswith('SIG') and not k.startswith('SIG_')}
  30 
  31 
  32 def get_signal_name(signum):
  33     """Returns the signal name of the given signal number."""
  34     return _signames[signum]
  35 
  36 
  37 # Not using future.backports.datetime here as datetime value might be an input from the user,
  38 # making every isinstace() call more delicate. So we just use our own compat layer.
  39 if hasattr(datetime, 'timestamp'):
  40     # Python 3.3+
  41     def _timestamp(dt_obj):
  42         return dt_obj.timestamp()
  43 else:
  44     # Python < 3.3 (incl 2.7)
  45     from time import mktime
  46 
  47     def _timestamp(dt_obj):
  48         return mktime(dt_obj.timetuple())
  49 
  50 
  51 def escape_markdown(text):
  52     """Helper function to escape telegram markup symbols."""
  53     escape_chars = '\*_`\['
  54     return re.sub(r'([%s])' % escape_chars, r'\\\1', text)
  55 
  56 
  57 def to_timestamp(dt_obj):
  58     """
  59     Args:
  60         dt_obj (:class:`datetime.datetime`):
  61 
  62     Returns:
  63         int:
  64 
  65     """
  66     if not dt_obj:
  67         return None
  68 
  69     return int(_timestamp(dt_obj))
  70 
  71 
  72 def from_timestamp(unixtime):
  73     """
  74     Args:
  75         unixtime (int):
  76 
  77     Returns:
  78         datetime.datetime:
  79 
  80     """
  81     if not unixtime:
  82         return None
  83 
  84     return datetime.fromtimestamp(unixtime)
  85 
  86 
  87 def mention_html(user_id, name):
  88     """
  89     Args:
  90         user_id (:obj:`int`) The user's id which you want to mention.
  91         name (:obj:`str`) The name the mention is showing.
  92 
  93     Returns:
  94         :obj:`str`: The inline mention for the user as html.
  95     """
  96     if isinstance(user_id, int):
  97         return '<a href="tg://user?id={}">{}</a>'.format(user_id, escape(name))
  98 
  99 
  100 def mention_markdown(user_id, name):
  101     """
  102     Args:
  103         user_id (:obj:`int`) The user's id which you want to mention.
  104         name (:obj:`str`) The name the mention is showing.
  105 
  106     Returns:
  107         :obj:`str`: The inline mention for the user as markdown.
  108     """
  109     if isinstance(user_id, int):
  110         return '[{}](tg://user?id={})'.format(escape_markdown(name), user_id)
  111 
  112 
  113 def effective_message_type(entity):
  114     """
  115     Extracts the type of message as a string identifier from a :class:`telegram.Message` or a
  116     :class:`telegram.Update`.
  117 
  118     Args:
  119         entity (:obj:`Update` | :obj:`Message`) The ``update`` or ``message`` to extract from
  120 
  121     Returns:
  122         str: One of ``Message.MESSAGE_TYPES``
  123 
  124     """
  125 
  126     # Importing on file-level yields cyclic Import Errors
  127     from telegram import Message
  128     from telegram import Update
  129 
  130     if isinstance(entity, Message):
  131         message = entity
  132     elif isinstance(entity, Update):
  133         message = entity.effective_message
  134     else:
  135         raise TypeError("entity is not Message or Update (got: {})".format(type(entity)))
  136 
  137     for i in Message.MESSAGE_TYPES:
  138         if getattr(message, i, None):
  139             return i
  140 
  141     return None
  142
  [end of telegram/utils/helpers.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/telegram/utils/helpers.py b/telegram/utils/helpers.py
  --- a/telegram/utils/helpers.py
  +++ b/telegram/utils/helpers.py
  @@ -94,7 +94,7 @@
           :obj:`str`: The inline mention for the user as html.
       """
       if isinstance(user_id, int):
  -        return '<a href="tg://user?id={}">{}</a>'.format(user_id, escape(name))
  +        return u'<a href="tg://user?id={}">{}</a>'.format(user_id, escape(name))
   
   
   def mention_markdown(user_id, name):
  @@ -107,7 +107,7 @@
           :obj:`str`: The inline mention for the user as markdown.
       """
       if isinstance(user_id, int):
  -        return '[{}](tg://user?id={})'.format(escape_markdown(name), user_id)
  +        return u'[{}](tg://user?id={})'.format(escape_markdown(name), user_id)
   
   
   def effective_message_type(entity):
  
verification_info: {"golden_diff": "diff --git a/telegram/utils/helpers.py b/telegram/utils/helpers.py\n--- a/telegram/utils/helpers.py\n+++ b/telegram/utils/helpers.py\n@@ -94,7 +94,7 @@\n         :obj:`str`: The inline mention for the user as html.\n     \"\"\"\n     if isinstance(user_id, int):\n-        return '<a href=\"tg://user?id={}\">{}</a>'.format(user_id, escape(name))\n+        return u'<a href=\"tg://user?id={}\">{}</a>'.format(user_id, escape(name))\n \n \n def mention_markdown(user_id, name):\n@@ -107,7 +107,7 @@\n         :obj:`str`: The inline mention for the user as markdown.\n     \"\"\"\n     if isinstance(user_id, int):\n-        return '[{}](tg://user?id={})'.format(escape_markdown(name), user_id)\n+        return u'[{}](tg://user?id={})'.format(escape_markdown(name), user_id)\n \n \n def effective_message_type(entity):\n", "issue": "Tests missing for `User.mention_markdown` and `User.mention_html`\nAnd while we're at it. Maybe `helpers.mention_markdown/html` too.\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2018\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains helper functions.\"\"\"\nfrom html import escape\n\nimport re\nimport signal\nfrom datetime import datetime\n\n# From https://stackoverflow.com/questions/2549939/get-signal-names-from-numbers-in-python\n_signames = {v: k\n             for k, v in reversed(sorted(vars(signal).items()))\n             if k.startswith('SIG') and not k.startswith('SIG_')}\n\n\ndef get_signal_name(signum):\n    \"\"\"Returns the signal name of the given signal number.\"\"\"\n    return _signames[signum]\n\n\n# Not using future.backports.datetime here as datetime value might be an input from the user,\n# making every isinstace() call more delicate. So we just use our own compat layer.\nif hasattr(datetime, 'timestamp'):\n    # Python 3.3+\n    def _timestamp(dt_obj):\n        return dt_obj.timestamp()\nelse:\n    # Python < 3.3 (incl 2.7)\n    from time import mktime\n\n    def _timestamp(dt_obj):\n        return mktime(dt_obj.timetuple())\n\n\ndef escape_markdown(text):\n    \"\"\"Helper function to escape telegram markup symbols.\"\"\"\n    escape_chars = '\\*_`\\['\n    return re.sub(r'([%s])' % escape_chars, r'\\\\\\1', text)\n\n\ndef to_timestamp(dt_obj):\n    \"\"\"\n    Args:\n        dt_obj (:class:`datetime.datetime`):\n\n    Returns:\n        int:\n\n    \"\"\"\n    if not dt_obj:\n        return None\n\n    return int(_timestamp(dt_obj))\n\n\ndef from_timestamp(unixtime):\n    \"\"\"\n    Args:\n        unixtime (int):\n\n    Returns:\n        datetime.datetime:\n\n    \"\"\"\n    if not unixtime:\n        return None\n\n    return datetime.fromtimestamp(unixtime)\n\n\ndef mention_html(user_id, name):\n    \"\"\"\n    Args:\n        user_id (:obj:`int`) The user's id which you want to mention.\n        name (:obj:`str`) The name the mention is showing.\n\n    Returns:\n        :obj:`str`: The inline mention for the user as html.\n    \"\"\"\n    if isinstance(user_id, int):\n        return '<a href=\"tg://user?id={}\">{}</a>'.format(user_id, escape(name))\n\n\ndef mention_markdown(user_id, name):\n    \"\"\"\n    Args:\n        user_id (:obj:`int`) The user's id which you want to mention.\n        name (:obj:`str`) The name the mention is showing.\n\n    Returns:\n        :obj:`str`: The inline mention for the user as markdown.\n    \"\"\"\n    if isinstance(user_id, int):\n        return '[{}](tg://user?id={})'.format(escape_markdown(name), user_id)\n\n\ndef effective_message_type(entity):\n    \"\"\"\n    Extracts the type of message as a string identifier from a :class:`telegram.Message` or a\n    :class:`telegram.Update`.\n\n    Args:\n        entity (:obj:`Update` | :obj:`Message`) The ``update`` or ``message`` to extract from\n\n    Returns:\n        str: One of ``Message.MESSAGE_TYPES``\n\n    \"\"\"\n\n    # Importing on file-level yields cyclic Import Errors\n    from telegram import Message\n    from telegram import Update\n\n    if isinstance(entity, Message):\n        message = entity\n    elif isinstance(entity, Update):\n        message = entity.effective_message\n    else:\n        raise TypeError(\"entity is not Message or Update (got: {})\".format(type(entity)))\n\n    for i in Message.MESSAGE_TYPES:\n        if getattr(message, i, None):\n            return i\n\n    return None\n", "path": "telegram/utils/helpers.py"}]}