def test_unicode_word_len(self): """Does the word counter eat unicode??""" u = u'Kim says: \u07c4\u07d0\u07f0\u07cb\u07f9' self.assertEqual(word_len(u), 3) b = b'Kim did not say: \xe3\xe3k' self.assertEqual(word_len(b), 5)
def create(self, validated_data): children = validated_data.pop("children") article = Article(**validated_data) if article.length is None: article.length = word_len(article.text) return (article, map(self.create, children))