Back to index

python3.2  3.2.2
Public Member Functions
test.test_codecs.IDNACodecTest Class Reference

List of all members.

Public Member Functions

def test_builtin_decode
def test_builtin_encode
def test_stream
def test_incremental_decode
def test_incremental_encode

Detailed Description

Definition at line 1116 of file test_codecs.py.


Member Function Documentation

Definition at line 1117 of file test_codecs.py.

01117 
01118     def test_builtin_decode(self):
01119         self.assertEqual(str(b"python.org", "idna"), "python.org")
01120         self.assertEqual(str(b"python.org.", "idna"), "python.org.")
01121         self.assertEqual(str(b"xn--pythn-mua.org", "idna"), "pyth\xf6n.org")
01122         self.assertEqual(str(b"xn--pythn-mua.org.", "idna"), "pyth\xf6n.org.")

Here is the call graph for this function:

Definition at line 1123 of file test_codecs.py.

01123 
01124     def test_builtin_encode(self):
01125         self.assertEqual("python.org".encode("idna"), b"python.org")
01126         self.assertEqual("python.org.".encode("idna"), b"python.org.")
01127         self.assertEqual("pyth\xf6n.org".encode("idna"), b"xn--pythn-mua.org")
01128         self.assertEqual("pyth\xf6n.org.".encode("idna"), b"xn--pythn-mua.org.")

Here is the call graph for this function:

Definition at line 1134 of file test_codecs.py.

01134 
01135     def test_incremental_decode(self):
01136         self.assertEqual(
01137             "".join(codecs.iterdecode((bytes([c]) for c in b"python.org"), "idna")),
01138             "python.org"
01139         )
01140         self.assertEqual(
01141             "".join(codecs.iterdecode((bytes([c]) for c in b"python.org."), "idna")),
01142             "python.org."
01143         )
01144         self.assertEqual(
01145             "".join(codecs.iterdecode((bytes([c]) for c in b"xn--pythn-mua.org."), "idna")),
01146             "pyth\xf6n.org."
01147         )
01148         self.assertEqual(
01149             "".join(codecs.iterdecode((bytes([c]) for c in b"xn--pythn-mua.org."), "idna")),
01150             "pyth\xf6n.org."
01151         )
01152 
01153         decoder = codecs.getincrementaldecoder("idna")()
01154         self.assertEqual(decoder.decode(b"xn--xam", ), "")
01155         self.assertEqual(decoder.decode(b"ple-9ta.o", ), "\xe4xample.")
01156         self.assertEqual(decoder.decode(b"rg"), "")
01157         self.assertEqual(decoder.decode(b"", True), "org")
01158 
01159         decoder.reset()
01160         self.assertEqual(decoder.decode(b"xn--xam", ), "")
01161         self.assertEqual(decoder.decode(b"ple-9ta.o", ), "\xe4xample.")
01162         self.assertEqual(decoder.decode(b"rg."), "org.")
01163         self.assertEqual(decoder.decode(b"", True), "")

Here is the call graph for this function:

Definition at line 1164 of file test_codecs.py.

01164 
01165     def test_incremental_encode(self):
01166         self.assertEqual(
01167             b"".join(codecs.iterencode("python.org", "idna")),
01168             b"python.org"
01169         )
01170         self.assertEqual(
01171             b"".join(codecs.iterencode("python.org.", "idna")),
01172             b"python.org."
01173         )
01174         self.assertEqual(
01175             b"".join(codecs.iterencode("pyth\xf6n.org.", "idna")),
01176             b"xn--pythn-mua.org."
01177         )
01178         self.assertEqual(
01179             b"".join(codecs.iterencode("pyth\xf6n.org.", "idna")),
01180             b"xn--pythn-mua.org."
01181         )
01182 
01183         encoder = codecs.getincrementalencoder("idna")()
01184         self.assertEqual(encoder.encode("\xe4x"), b"")
01185         self.assertEqual(encoder.encode("ample.org"), b"xn--xample-9ta.")
01186         self.assertEqual(encoder.encode("", True), b"org")
01187 
01188         encoder.reset()
01189         self.assertEqual(encoder.encode("\xe4x"), b"")
01190         self.assertEqual(encoder.encode("ample.org."), b"xn--xample-9ta.org.")
01191         self.assertEqual(encoder.encode("", True), b"")

Here is the call graph for this function:

Definition at line 1129 of file test_codecs.py.

01129 
01130     def test_stream(self):
01131         r = codecs.getreader("idna")(io.BytesIO(b"abc"))
01132         r.read(3)
01133         self.assertEqual(r.read(), "")

Here is the call graph for this function:


The documentation for this class was generated from the following file: