Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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))
Ejemplo n.º 3
0
    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))