Ejemplo n.º 1
0
 def setup_class(cls):
     if not hasattr(os, "fork"):
         py.test.skip("Need fork() to test wait3/wait4()")
     rebuild.rebuild_one('resource.ctc.py')
     cls.w__pypy_wait = import_lib_pypy(
         cls.space, '_pypy_wait',
         '_pypy_wait not supported on this platform')
Ejemplo n.º 2
0
 def setup_class(cls):
     if not hasattr(os, "fork"):
         py.test.skip("Need fork() to test wait3/wait4()")
     rebuild.rebuild_one('resource.ctc.py')
     cls.w__pypy_wait = import_lib_pypy(
         cls.space, '_pypy_wait',
         '_pypy_wait not supported on this platform')
Ejemplo n.º 3
0
from __future__ import absolute_import
import py
import sys

from lib_pypy.ctypes_config_cache import rebuild
rebuild.rebuild_one('locale.ctc.py')

from lib_pypy 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)
Ejemplo n.º 4
0
# XXX TypeErrors on calling handlers, or on bad return values from a
# handler, are obscure and unhelpful.

from __future__ import absolute_import
import StringIO, sys
import unittest, py

from lib_pypy.ctypes_config_cache import rebuild
rebuild.rebuild_one('pyexpat.ctc.py')

from lib_pypy 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
Ejemplo n.º 5
0
 def setup_class(cls):
     rebuild.rebuild_one('resource.ctc.py')
     cls.w_resource = import_lib_pypy(cls.space, 'resource',
                                      'No resource module available')
Ejemplo n.º 6
0
# Generates the resource cache
from __future__ import absolute_import
from lib_pypy.ctypes_config_cache import rebuild
rebuild.rebuild_one('resource.ctc.py')

import os

from lib_pypy._pypy_wait import wait3, wait4

if hasattr(os, 'wait3'):
    def test_os_wait3():
        exit_status = 0x33

        if not hasattr(os, "fork"):
            skip("Need fork() to test wait3()")

        child = os.fork()
        if child == 0: # in child
            os._exit(exit_status)
        else:
            pid, status, rusage = wait3(0)
            assert child == pid
            assert os.WIFEXITED(status)
            assert os.WEXITSTATUS(status) == exit_status
            assert isinstance(rusage.ru_utime, float)
            assert isinstance(rusage.ru_maxrss, int)

if hasattr(os, 'wait4'):
    def test_os_wait4():
        exit_status = 0x33
Ejemplo n.º 7
0
# Generates the resource cache
from __future__ import absolute_import
from lib_pypy.ctypes_config_cache import rebuild

rebuild.rebuild_one("resource.ctc.py")

import os

from lib_pypy._pypy_wait import wait3, wait4

if hasattr(os, "wait3"):

    def test_os_wait3():
        exit_status = 0x33

        if not hasattr(os, "fork"):
            skip("Need fork() to test wait3()")

        child = os.fork()
        if child == 0:  # in child
            os._exit(exit_status)
        else:
            pid, status, rusage = wait3(0)
            assert child == pid
            assert os.WIFEXITED(status)
            assert os.WEXITSTATUS(status) == exit_status
            assert isinstance(rusage.ru_utime, float)
            assert isinstance(rusage.ru_maxrss, int)


if hasattr(os, "wait4"):
Ejemplo n.º 8
0
from __future__ import absolute_import
import py
import sys

from lib_pypy.ctypes_config_cache import rebuild
rebuild.rebuild_one('locale.ctc.py')

from lib_pypy 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):
Ejemplo n.º 9
0
from __future__ import absolute_import
# XXX very minimal test

from lib_pypy.ctypes_config_cache import rebuild
rebuild.rebuild_one('syslog.ctc.py')

from lib_pypy import syslog


def test_syslog():
    assert hasattr(syslog, 'LOG_ALERT')
Ejemplo n.º 10
0
# XXX TypeErrors on calling handlers, or on bad return values from a
# handler, are obscure and unhelpful.

from __future__ import absolute_import
import StringIO, sys
import unittest, py

from lib_pypy.ctypes_config_cache import rebuild

rebuild.rebuild_one('pyexpat.ctc.py')

from lib_pypy 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
Ejemplo n.º 11
0
from __future__ import absolute_import
from lib_pypy.ctypes_config_cache import rebuild
rebuild.rebuild_one('resource.ctc.py')

from lib_pypy 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)
Ejemplo n.º 12
0
 def setup_class(cls):
     rebuild.rebuild_one('resource.ctc.py')
     cls.w_resource = import_lib_pypy(cls.space, 'resource',
                                      'No resource module available')