from pypy.lib.ctypes_config_cache import rebuild rebuild.rebuild_one('resource.ctc.py') from pypy.lib import resource def test_resource(): x = resource.getrusage(resource.RUSAGE_SELF) assert len(x) == 16 assert x[0] == x[-16] == x.ru_utime assert x[1] == x[-15] == x.ru_stime assert x[2] == x[-14] == x.ru_maxrss assert x[3] == x[-13] == x.ru_ixrss assert x[4] == x[-12] == x.ru_idrss assert x[5] == x[-11] == x.ru_isrss assert x[6] == x[-10] == x.ru_minflt assert x[7] == x[-9] == x.ru_majflt assert x[8] == x[-8] == x.ru_nswap assert x[9] == x[-7] == x.ru_inblock assert x[10] == x[-6] == x.ru_oublock assert x[11] == x[-5] == x.ru_msgsnd assert x[12] == x[-4] == x.ru_msgrcv assert x[13] == x[-3] == x.ru_nsignals assert x[14] == x[-2] == x.ru_nvcsw assert x[15] == x[-1] == x.ru_nivcsw for i in range(16): if i < 2: expected_type = float else: expected_type = (int, long) assert isinstance(x[i], expected_type)
# XXX very minimal test from pypy.lib.ctypes_config_cache import rebuild rebuild.rebuild_one('syslog.ctc.py') from pypy.lib import syslog def test_syslog(): assert hasattr(syslog, 'LOG_ALERT')
from pypy.lib.ctypes_config_cache import rebuild rebuild.rebuild_one('hashlib.ctc.py') from pypy.lib import hashlib, _hashlib def test_unicode(): assert isinstance(hashlib.new('sha1', u'xxx'), _hashlib.hash) def test_attributes(): for name, expected_size in {'md5': 16, 'sha1': 20, 'sha224': 28, 'sha256': 32, 'sha384': 48, 'sha512': 64, }.items(): h = hashlib.new(name) assert h.digest_size == expected_size assert h.digestsize == expected_size # h.update('abc') h2 = h.copy() h.update('def') digest = h.digest() hexdigest = h.hexdigest() h2.update('d') h2.update('ef') assert digest == h.digest() assert hexdigest == h.hexdigest() # also test the pure Python implementation
import py import sys from pypy.lib.ctypes_config_cache import rebuild rebuild.rebuild_one('locale.ctc.py') from pypy.lib import _locale def setup_module(mod): if sys.platform == 'darwin': py.test.skip("Locale support on MacOSX is minimal and cannot be tested") class TestLocale: def setup_class(cls): cls.oldlocale = _locale.setlocale(_locale.LC_NUMERIC) if sys.platform.startswith("win"): cls.tloc = "en" elif sys.platform.startswith("freebsd"): cls.tloc = "en_US.US-ASCII" else: cls.tloc = "en_US.UTF8" try: _locale.setlocale(_locale.LC_NUMERIC, cls.tloc) except _locale.Error: py.test.skip("test locale %s not supported" % cls.tloc) def teardown_class(cls): _locale.setlocale(_locale.LC_NUMERIC, cls.oldlocale) def test_format(self):
# XXX TypeErrors on calling handlers, or on bad return values from a # handler, are obscure and unhelpful. import StringIO, sys import unittest, py from pypy.lib.ctypes_config_cache import rebuild rebuild.rebuild_one('pyexpat.ctc.py') from pypy.lib import pyexpat #from xml.parsers import expat expat = pyexpat from test.test_support import sortdict, run_unittest class TestSetAttribute: def setup_method(self, meth): self.parser = expat.ParserCreate(namespace_separator='!') self.set_get_pairs = [ [0, 0], [1, 1], [2, 1], [0, 0], ] def test_returns_unicode(self): for x, y in self.set_get_pairs: self.parser.returns_unicode = x assert self.parser.returns_unicode == y