File: test_codecs.py

package info (click to toggle)
pypy3 7.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,848 kB
  • sloc: python: 1,291,746; ansic: 74,281; asm: 5,187; cpp: 3,017; sh: 2,533; makefile: 544; xml: 243; lisp: 45; csh: 21; awk: 4
file content (15 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# encoding: iso-8859-15
from pypy.module.cpyext.test.test_api import BaseApiTest
from rpython.rtyper.lltypesystem import rffi
from pypy.module.cpyext.codecs import (
    PyCodec_IncrementalEncoder, PyCodec_IncrementalDecoder)

class TestCodecs(BaseApiTest):
    def test_incremental(self, space):
        utf8 = rffi.str2charp('utf-8')
        w_encoder = PyCodec_IncrementalEncoder(space, utf8, None)
        w_encoded = space.call_method(w_encoder, 'encode', space.wrap(u'späm'))
        w_decoder = PyCodec_IncrementalDecoder(space, utf8, None)
        w_decoded = space.call_method(w_decoder, 'decode', w_encoded)
        assert space.unicode_w(w_decoded) == u'späm'
        rffi.free_charp(utf8)