def save(self, *args, **kwargs): # Convert emoji because emoji break MySQL self.description = convert_emoji(self.description) # Truncate the description self.description = self.description.strip()[:TRUNCATE_LENGTH] super(Response, self).save(*args, **kwargs)
def save(self, *args, **kwargs): # Convert emoji because emoji break MySQL self.description = convert_emoji(self.description) # Truncate the description self.description = self.description.strip()[:TRUNCATE_LENGTH] super(Response, self).save(*args, **kwargs)
def test_unicodedata(self): """Remove emoji if unicodedata2 is not installed""" with import_unicodedata(): assert convert_emoji(u'Example \U0001f62a') == 'Example '
def test_sleepy_face(self): """Replace emoji with name if unicodedata2 is installed""" assert convert_emoji(u'Example \U0001f62a') == 'Example SLEEPY FACE'
def test_no_emoji(self): assert convert_emoji(u'Example example') == 'Example example'