test_softspace.py 640 B

1234567891011121314151617181920212223
  1. from test.test_support import run_unittest
  2. import unittest
  3. import StringIO
  4. class SoftspaceTests(unittest.TestCase):
  5. def test_bug_480215(self):
  6. # SF bug 480215: softspace confused in nested print
  7. f = StringIO.StringIO()
  8. class C:
  9. def __str__(self):
  10. print >> f, 'a'
  11. return 'b'
  12. print >> f, C(), 'c ', 'd\t', 'e'
  13. print >> f, 'f', 'g'
  14. # In 2.2 & earlier, this printed ' a\nbc d\te\nf g\n'
  15. self.assertEqual(f.getvalue(), 'a\nb c d\te\nf g\n')
  16. def test_main():
  17. run_unittest(SoftspaceTests)
  18. if __name__ == '__main__':
  19. test_main()