def test_wikipedia_entry(self):
        decoded = StringIO()
        encoded = StringIO()

        input = """25\r\nThis is the data in the first chunk\r\n\r\n1C\r\nand this is the second one\r\n\r\n3\r\ncon\r\n8\r\nsequence\r\n0\r\n\r\n"""
        output = """This is the data in the first chunk\r\nand this is the second one\r\nconsequence"""

        for chunk in chunks.decode(StringIO(input)):
            decoded.write(chunk)

        decoded.seek(0)

        for chunk in chunks.encode(decoded):
            encoded.write(chunk)

        decoded = StringIO()
        encoded.seek(0)

        for chunk in chunks.decode(StringIO(input)):
            decoded.write(chunk)

        self.assertEqual(output, decoded.getvalue())
    def test_decode(self):
        fileobj = StringIO(string.join(testdata_out, ''))

        for found, expected in zip(list(chunks.decode(fileobj)), (string.join(o, '') for o in grouper(4, testdata_in, ''))):
            self.assertEqual(found, expected)