X Tutup
Skip to content

Commit cbfb7df

Browse files
nmlorgjh0ker
authored andcommitted
Explicitly make Bot.full_name return a unicode object, rather than implicitly a unicode object in Python 3 and a str object on Python 2. (python-telegram-bot#1063)
1 parent 712baf0 commit cbfb7df

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

telegram/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def full_name(self):
8888
8989
"""
9090
if self.last_name:
91-
return '{} {}'.format(self.first_name, self.last_name)
91+
return u'{} {}'.format(self.first_name, self.last_name)
9292
return self.first_name
9393

9494
@classmethod

tests/test_user.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def user(bot):
4242
class TestUser(object):
4343
id = 1
4444
is_bot = True
45-
first_name = 'first_name'
46-
last_name = 'last_name'
45+
first_name = u'first\u2022name'
46+
last_name = u'last\u2022name'
4747
username = 'username'
4848
language_code = 'en_us'
4949

@@ -85,16 +85,16 @@ def test_de_json_without_username_and_last_name(self, json_dict, bot):
8585
def test_name(self, user):
8686
assert user.name == '@username'
8787
user.username = None
88-
assert user.name == 'first_name last_name'
88+
assert user.name == u'first\u2022name last\u2022name'
8989
user.last_name = None
90-
assert user.name == 'first_name'
90+
assert user.name == u'first\u2022name'
9191
user.username = self.username
9292
assert user.name == '@username'
9393

9494
def test_full_name(self, user):
95-
assert user.full_name == 'first_name last_name'
95+
assert user.full_name == u'first\u2022name last\u2022name'
9696
user.last_name = None
97-
assert user.full_name == 'first_name'
97+
assert user.full_name == u'first\u2022name'
9898

9999
def test_get_profile_photos(self, monkeypatch, user):
100100
def test(_, *args, **kwargs):

0 commit comments

Comments
 (0)
X Tutup