def test_fill_with_breaks(self): # Demonstrate complicated case. text = u"spam ham egg spamhamegg" + _str_D + u" spam" + _str_D * 2 self.assertEqual( u'\n'.join([ "spam ham", "egg spam", "hamegg" + _str_D[0], _str_D[1:], "spam" + _str_D[:2], _str_D[2:] + _str_D[:2], _str_D[2:] ]), utextwrap.fill(text, 8))
def test_fill_with_breaks(self): # Demonstrate complicated case. text = u"spam ham egg spamhamegg" + _str_D + u" spam" + _str_D*2 self.assertEqual(u'\n'.join(["spam ham", "egg spam", "hamegg" + _str_D[0], _str_D[1:], "spam" + _str_D[:2], _str_D[2:]+_str_D[:2], _str_D[2:]]), utextwrap.fill(text, 8))
def test_fill_without_breaks(self): text = u"spam ham egg spamhamegg" + _str_D + u" spam" + _str_D*2 self.assertEqual(u'\n'.join(["spam ham", "egg", "spamhamegg", # border between single width and double # width. _str_D, "spam" + _str_D[:2], _str_D[2:]+_str_D[:2], _str_D[2:]]), utextwrap.fill(text, 8, break_long_words=False))
def test_fill_without_breaks(self): text = u"spam ham egg spamhamegg" + _str_D + u" spam" + _str_D * 2 self.assertEqual( u'\n'.join([ "spam ham", "egg", "spamhamegg", # border between single width and double # width. _str_D, "spam" + _str_D[:2], _str_D[2:] + _str_D[:2], _str_D[2:] ]), utextwrap.fill(text, 8, break_long_words=False))
def test_fill_simple(self): # Test only can call fill() because it's just '\n'.join(wrap(text)). self.assertEqual("%s\n%s" % (_str_D[:2], _str_D[2:]), utextwrap.fill(_str_D, 4))