Esempio 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[:] = []
Esempio 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[:] = []
Esempio 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""")
Esempio 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
Esempio 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
Esempio 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
Esempio 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[:] = []
Esempio 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')
Esempio 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[:] = []
Esempio 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
Esempio 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