Changeset 178:37f36ea93838 for wokkel/test/test_generic.py
- Timestamp:
- Jan 12, 2013, 4:40:38 PM (9 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/test/test_generic.py
r171 r178 269 269 """ 270 270 self.assertIdentical(None, self.request.timeout) 271 272 273 274 class PrepareIDNNameTests(unittest.TestCase): 275 """ 276 Tests for L{wokkel.generic.prepareIDNName}. 277 """ 278 279 def test_bytestring(self): 280 """ 281 An ASCII-encoded byte string is left as-is. 282 """ 283 name = b"example.com" 284 result = generic.prepareIDNName(name) 285 self.assertEqual(b"example.com", result) 286 287 288 def test_unicode(self): 289 """ 290 A unicode all-ASCII name is converted to an ASCII byte string. 291 """ 292 name = u"example.com" 293 result = generic.prepareIDNName(name) 294 self.assertEqual(b"example.com", result) 295 296 297 def test_unicodeNonASCII(self): 298 """ 299 A unicode with non-ASCII is converted to its ACE equivalent. 300 """ 301 name = u"\u00e9chec.example.com" 302 result = generic.prepareIDNName(name) 303 self.assertEqual(b"xn--chec-9oa.example.com", result) 304 305 306 def test_unicodeHalfwidthIdeographicFullStop(self): 307 """ 308 Exotic dots in unicode names are converted to Full Stop. 309 """ 310 name = u"\u00e9chec.example\uff61com" 311 result = generic.prepareIDNName(name) 312 self.assertEqual(b"xn--chec-9oa.example.com", result) 313 314 315 def test_unicodeTrailingDot(self): 316 """ 317 Unicode names with trailing dots retain the trailing dot. 318 319 L{encodings.idna.ToASCII} doesn't allow the empty string as the input, 320 hence the implementation needs to strip a trailing dot, and re-add it 321 after encoding the labels. 322 """ 323 name = u"example.com." 324 result = generic.prepareIDNName(name) 325 self.assertEqual(b"example.com.", result)
Note: See TracChangeset
for help on using the changeset viewer.