Ejemplo n.º 1
0
 def setup_class(cls):
     cls.space = gettestobjspace(usemodules=['cpyext', 'thread', '_rawffi'])
     cls.space.getbuiltinmodule("cpyext")
     from pypy.module.imp.importing import importhook
     importhook(cls.space, "os") # warm up reference counts
     state = cls.space.fromcache(RefcountState)
     state.non_heaptypes_w[:] = []
Ejemplo n.º 2
0
 def setup_class(cls):
     cls.space = gettestobjspace(usemodules=['cpyext', 'thread', '_rawffi'])
     cls.space.getbuiltinmodule("cpyext")
     from pypy.module.imp.importing import importhook
     importhook(cls.space, "os")  # warm up reference counts
     state = cls.space.fromcache(RefcountState)
     state.non_heaptypes_w[:] = []
Ejemplo n.º 3
0
    def setup_class(cls):
        # following from AppTestCpythonExtensionBase, with cppyy added
        cls.space = gettestobjspace(usemodules=['cpyext', 'cppyy', 'thread', '_rawffi', '_ffi', 'array'])
        cls.space.getbuiltinmodule("cpyext")
        from pypy.module.imp.importing import importhook
        importhook(cls.space, "os") # warm up reference counts
        from pypy.module.cpyext.pyobject import RefcountState
        state = cls.space.fromcache(RefcountState)
        state.non_heaptypes_w[:] = []

        # cppyy specific additions (not that the test_dct is loaded late
        # to allow the generated extension module be loaded first)
        cls.w_test_dct  = cls.space.wrap(test_dct)
        cls.w_datatypes = cls.space.appexec([], """():
            import cppyy, cpyext""")
Ejemplo n.º 4
0
    def test_lock(self, space, monkeypatch):
        from pypy.module.imp.importing import getimportlock, importhook

        # Force importing the module _file now
        space.builtin.get('file')

        # Monkeypatch the import lock and add a counter
        importlock = getimportlock(space)
        original_acquire = importlock.acquire_lock
        def acquire_lock():
            importlock.count += 1
            original_acquire()
        importlock.count = 0
        monkeypatch.setattr(importlock, 'acquire_lock', acquire_lock)

        # An already imported module
        importhook(space, 'sys')
        assert importlock.count == 0
        # A new module
        importhook(space, 're')
        assert importlock.count == 9
        # Import it again
        previous_count = importlock.count
        importhook(space, 're')
        assert importlock.count == previous_count
Ejemplo n.º 5
0
    def test_lock(self, space, monkeypatch):
        from pypy.module.imp.importing import getimportlock, importhook

        # Force importing the module _file now
        space.builtin.get('file')

        # Monkeypatch the import lock and add a counter
        importlock = getimportlock(space)
        original_acquire = importlock.acquire_lock

        def acquire_lock():
            importlock.count += 1
            original_acquire()

        importlock.count = 0
        monkeypatch.setattr(importlock, 'acquire_lock', acquire_lock)

        # An already imported module
        importhook(space, 'sys')
        assert importlock.count == 0
        # A new module
        importhook(space, 're')
        assert importlock.count == 7
        # Import it again
        previous_count = importlock.count
        importhook(space, 're')
        assert importlock.count == previous_count
Ejemplo n.º 6
0
    def test_lock(self, space, monkeypatch):
        from pypy.module.imp.importing import getimportlock, importhook

        # Monkeypatch the import lock and add a counter
        importlock = getimportlock(space)
        original_acquire = importlock.acquire_lock
        def acquire_lock():
            importlock.count += 1
            original_acquire()
        importlock.count = 0
        monkeypatch.setattr(importlock, 'acquire_lock', acquire_lock)

        # An already imported module
        importhook(space, 'sys')
        assert importlock.count == 0
        # A new module
        importhook(space, '__future__')
        assert importlock.count == 1
        # Import it again
        previous_count = importlock.count
        importhook(space, '__future__')
        assert importlock.count == previous_count
Ejemplo n.º 7
0
 def setup_class(cls):
     cls.space.getbuiltinmodule("cpyext")
     from pypy.module.imp.importing import importhook
     importhook(cls.space, "os") # warm up reference counts
     state = cls.space.fromcache(RefcountState)
     state.non_heaptypes_w[:] = []
Ejemplo n.º 8
0
 def startup(self, space):
     from pypy.module.posix import interp_posix
     from pypy.module.imp import importing
     interp_posix.get(space).startup(space)
     # Import structseq before the full importlib is ready
     importing.importhook(space, '_structseq')
Ejemplo n.º 9
0
 def setup_class(cls):
     cls.space.getbuiltinmodule("cpyext")
     from pypy.module.imp.importing import importhook
     importhook(cls.space, "os")  # warm up reference counts
     state = cls.space.fromcache(RefcountState)
     state.non_heaptypes_w[:] = []
Ejemplo n.º 10
0
 def setup_class(cls):
     cls.space.getbuiltinmodule("cpyext")
     from pypy.module.imp.importing import importhook
     importhook(cls.space, "os") # warm up reference counts
Ejemplo n.º 11
0
 def setup_class(cls):
     cls.space.getbuiltinmodule("cpyext")
     from pypy.module.imp.importing import importhook
     importhook(cls.space, "os")  # warm up reference counts