Example #1
0
 def __repr__(self):
     '''Returns a string representation for debugging.'''
     class_name = self.__class__.__name__
     text = self.__unicode__().encode("utf-8") if PY2 else str(self)
     ret = '{cls}("{text}")'.format(cls=class_name,
                                     text=text)
     return binary_type(ret) if PY2 else ret
Example #2
0
 def __repr__(self):
     '''Returns a string representation for debugging.'''
     class_name = self.__class__.__name__
     text = self.__unicode__().encode("utf-8") if PY2 else str(self)
     ret = '{cls}("{text}")'.format(cls=class_name,
                                     text=text)
     return binary_type(ret) if PY2 else ret
Example #3
0
 def test_repr(self):
     # In Py2, repr returns bytestring
     if PY2:
         assert_equal(repr(self.sentence),
                     b"Sentence(\"{0}\")".format(binary_type(self.raw_sentence)))
     # In Py3, returns text type string
     else:
         assert_equal(repr(self.sentence), 'Sentence("{0}")'.format(self.raw_sentence))
Example #4
0
 def test_repr(self):
     # In Py2, repr returns bytestring
     if PY2:
         assert_equal(repr(self.sentence),
                     b"Sentence(\"{0}\")".format(binary_type(self.raw_sentence)))
     # In Py3, returns text type string
     else:
         assert_equal(repr(self.sentence), 'Sentence("{0}")'.format(self.raw_sentence))
Example #5
0
 def test_repr(self):
     blob1 = tb.TextBlob('lorem ipsum')
     if PY2:
         assert_equal(
             repr(blob1),
             b"TextBlob(\"{0}\")".format(binary_type('lorem ipsum')))
     else:
         assert_equal(repr(blob1),
                      "TextBlob(\"{0}\")".format('lorem ipsum'))
Example #6
0
 def test_repr(self):
     blob1 = tb.TextBlob('lorem ipsum')
     if PY2:
         assert_equal(repr(blob1), b"TextBlob(\"{0}\")".format(binary_type('lorem ipsum')))
     else:
         assert_equal(repr(blob1), "TextBlob(\"{0}\")".format('lorem ipsum'))