class RawOutputFormatTest(TestCase): """Test te formatter to ensure it can deal with mbcs.""" @defer.inlineCallbacks def setUp(self): yield super(RawOutputFormatTest, self).setUp() self.format = {'normal': 'normal'} self.formatter = RawOutputFormat(self.format) def test_simple_unicode(self): """Test the formatting of a simple value that is unicode.""" attr = 'attribute' self.format[attr] = attr value = u'ñoño' expected_result = (attr + value.encode( sys.getfilesystemencoding(), 'replace') + self.format['normal']) self.assertEqual(expected_result, self.formatter.simple(value, attr)) def test_simple_not_unicode(self): """Test the formatting of a simple value that is not unicode.""" attr = 'attribute' self.format[attr] = attr value = True expected_result = (attr + str(value) + self.format['normal']) self.assertEqual(expected_result, self.formatter.simple(value, attr))
def setUp(self): yield super(RawOutputFormatTest, self).setUp() self.format = {'normal': 'normal'} self.formatter = RawOutputFormat(self.format)