You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compat_tests.py 638B

12345678910111213141516171819202122
  1. # -*- coding: utf-8 -*-
  2. import datetime
  3. from six.moves import cStringIO
  4. from django.test import TestCase
  5. from oscar.core.compat import UnicodeCSVWriter
  6. class TestUnicodeCSVWriter(TestCase):
  7. def test_can_write_different_values(self):
  8. writer = UnicodeCSVWriter(open_file=cStringIO())
  9. s = u'ünįcodē'
  10. class unicodeobj(object):
  11. def __str__(self):
  12. return s
  13. def __unicode__(self):
  14. return s
  15. rows = [[s, unicodeobj(), 123, datetime.date.today()], ]
  16. writer.writerows(rows)
  17. self.assertRaises(TypeError, writer.writerows, [object()])