[pypy-commit] pypy kill-import_from_lib_pypy: fix and refine lib_pypy/pypy_test/test_os_wait.py
RonnyPfannschmidt
noreply at buildbot.pypy.org
Sun Jul 1 13:52:46 CEST 2012
Author: Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
Branch: kill-import_from_lib_pypy
Changeset: r55878:416df6469990
Date: 2012-07-01 13:48 +0200
http://bitbucket.org/pypy/pypy/changeset/416df6469990/
Log: fix and refine lib_pypy/pypy_test/test_os_wait.py
diff --git a/lib_pypy/pypy_test/test_os_wait.py b/lib_pypy/pypy_test/test_os_wait.py
--- a/lib_pypy/pypy_test/test_os_wait.py
+++ b/lib_pypy/pypy_test/test_os_wait.py
@@ -1,44 +1,50 @@
-# 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
+import pytest
+from pypy.tool.lib_pypy import ctypes_cachedir, rebuild_one
-import os
-from lib_pypy._pypy_wait import wait3, wait4
+def setup_module(mod):
+ # Generates the resource cache
+ rebuild_one(ctypes_cachedir.join('resource.ctc.py'))
+ if not hasattr(os, 'fork'):
+ pytest.skip("can't test wait without fork")
-if hasattr(os, 'wait3'):
- def test_os_wait3():
- exit_status = 0x33
- if not hasattr(os, "fork"):
- skip("Need fork() to test wait3()")
+def test_os_wait3():
+ #XXX: have skip_if deco
+ if not hasattr(os, 'wait3'):
+ pytest.skip('no os.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)
+ from lib_pypy._pypy_wait import wait3
+ exit_status = 0x33
-if hasattr(os, 'wait4'):
- def test_os_wait4():
- exit_status = 0x33
+ 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 not hasattr(os, "fork"):
- skip("Need fork() to test wait4()")
+def test_os_wait4():
+ #XXX: have skip_if deco
+ if not hasattr(os, 'wait4'):
+ pytest.skip('no os.wait4')
- child = os.fork()
- if child == 0: # in child
- os._exit(exit_status)
- else:
- pid, status, rusage = wait4(child, 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)
+ from lib_pypy._pypy_wait import wait4
+ exit_status = 0x33
+
+ child = os.fork()
+ if child == 0: # in child
+ os._exit(exit_status)
+ else:
+ pid, status, rusage = wait4(child, 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)
diff --git a/pypy/tool/lib_pypy.py b/pypy/tool/lib_pypy.py
--- a/pypy/tool/lib_pypy.py
+++ b/pypy/tool/lib_pypy.py
@@ -51,11 +51,9 @@
def rebuild_one(path):
filename = str(path)
d = {'__file__': filename}
- try:
- execfile(filename, d)
- finally:
- base = path.basename.split('.')[0]
- dumpcache2(base, d['config'], filename)
+ execfile(filename, d)
+ base = path.basename.split('.')[0]
+ dumpcache2(base, d['config'], filename)
def try_rebuild():
More information about the pypy-commit
mailing list