1 # -*- coding: utf-8 -*-
3 from tests
.baseclass
import *
5 from pykickstart
import constants
6 from pykickstart
.errors
import KickstartParseError
7 from pykickstart
import version
9 class HandleUnicode_TestCase(ParserTest
):
19 unicode_str1
= u
"ááááááááá"
20 unicode_str2
= u
"áááááá"
21 encoded_str1
= unicode_str1
.encode("utf-8")
22 encoded_str2
= unicode_str2
.encode("utf-8")
24 # parser should parse string including non-ascii characters
25 self
.parser
.readKickstartFromString(self
.ks
)
27 # str(handler) should not cause traceback and should contain the
28 # original non-ascii strings as utf-8 encoded byte strings and
29 # str(self.handler) should not fail -- i.e. self.handler.__str__()
30 # should return byte string not unicode string
31 self
.assertIn(encoded_str1
, str(self
.handler
))
32 self
.assertIn(encoded_str2
, str(self
.handler
))
34 # set root password to unicode string
35 self
.handler
.rootpw
.password
= unicode_str1
37 # str(handler) should not cause traceback and should contain the
38 # original unicode string as utf-8 encoded byte string
39 self
.assertIn(encoded_str1
, str(self
.handler
))
41 # set root password to encoded string
42 self
.handler
.rootpw
.password
= encoded_str1
44 # str(handler) should not cause traceback and should contain the
45 # original unicode string as utf-8 encoded byte string
46 self
.assertIn(encoded_str1
, str(self
.handler
))
48 if __name__
== "__main__":