Commit 2060df4d authored by Armin Rigo's avatar Armin Rigo
Browse files

Import posix directly instead of os; import nt on win32

parent 037744e9abc7
# import posix underneath import sys
from os import environ if sys.platform == 'win32':
import nt as posix
else:
import posix
# for the test_random_stuff_can_unfreeze test # for the test_random_stuff_can_unfreeze test
environ['PYPY_DEMO_MODULE_ERROR'] = '1' posix.environ['PYPY_DEMO_MODULE_ERROR'] = '1'
class DemoError(Exception): class DemoError(Exception):
pass pass
import sys
from pypy.module._demo.moduledef import Module from pypy.module._demo.moduledef import Module
from pypy.tool.option import make_config, make_objspace from pypy.tool.option import make_config, make_objspace
...@@ -29,8 +30,11 @@ class TestImport: ...@@ -29,8 +30,11 @@ class TestImport:
assert space.getattr(w_demo, space.wrap('measuretime')) assert space.getattr(w_demo, space.wrap('measuretime'))
posixname = 'posix' if sys.platform != 'win32' else 'nt'
class TestMixedModuleUnfreeze: class TestMixedModuleUnfreeze:
spaceconfig = dict(usemodules=('_demo', 'posix')) spaceconfig = dict(usemodules=('_demo', posixname))
def test_random_stuff_can_unfreeze(self): def test_random_stuff_can_unfreeze(self):
# When a module contains an "import" statement in applevel code, the # When a module contains an "import" statement in applevel code, the
...@@ -40,7 +44,7 @@ class TestMixedModuleUnfreeze: ...@@ -40,7 +44,7 @@ class TestMixedModuleUnfreeze:
# This is important when the module startup() function does something # This is important when the module startup() function does something
# at runtime, like setting os.environ (posix module) or initializing # at runtime, like setting os.environ (posix module) or initializing
# the winsock library (_socket module) # the winsock library (_socket module)
w_posix = self.space.builtin_modules['posix'] w_posix = self.space.builtin_modules[posixname]
w_demo = self.space.builtin_modules['_demo'] w_demo = self.space.builtin_modules['_demo']
w_posix._cleanup_() w_posix._cleanup_()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment