Пример #1
0
            libfile = os.path.join(sys._MEIPASS, %(soname)r)
            print(libfile)
            assert os.path.isfile(libfile), '%(soname)s is missing'
            print('>>> file found')
    """

parameters = []
ids = []
for prefix in ('', 'ctypes.'):
    for funcname in  ('CDLL', 'PyDLL', 'WinDLL', 'OleDLL', 'cdll.LoadLibrary'):
        ids.append(prefix+funcname)
        params = (prefix+funcname, ids[-1])
        # Marking doesn't seem to chain here, so select just one skippping mark
        # instead of both.
        if not has_compiler:
            params = skipif_no_compiler(params)
        elif funcname in ("WinDLL", "OleDLL"):
            # WinDLL, OleDLL only work on windows.
            params = skipif_notwin(params)
        parameters.append(params)

@pytest.mark.parametrize("funcname,test_id", parameters, ids=ids)
def test_ctypes_gen(pyi_builder, monkeypatch, funcname, compiled_dylib, test_id):
    # evaluate the soname here, so the test-code contains a constant.
    # We want the name of the dynamically-loaded library only, not its path.
    # See discussion in https://github.com/pyinstaller/pyinstaller/pull/1478#issuecomment-139622994.
    soname = compiled_dylib.basename

    source = """
        import ctypes ; from ctypes import *
        lib = %s(%%(soname)r)
Пример #2
0
            libfile = os.path.join(sys._MEIPASS, %(soname)r)
            print(libfile)
            assert os.path.isfile(libfile), '%(soname)s is missing'
            print('>>> file found')
    """

parameters = []
ids = []
for prefix in ('', 'ctypes.'):
    for funcname in ('CDLL', 'PyDLL', 'WinDLL', 'OleDLL', 'cdll.LoadLibrary'):
        ids.append(prefix + funcname)
        params = (prefix + funcname, ids[-1])
        # Marking doesn't seem to chain here, so select just one skippping mark
        # instead of both.
        if not has_compiler:
            params = pytest.param(*params, marks=skipif_no_compiler(params))
        elif funcname in ("WinDLL", "OleDLL"):
            # WinDLL, OleDLL only work on windows.
            params = pytest.param(*params, marks=pytest.mark.win32)
        parameters.append(params)


@pytest.mark.parametrize("funcname,test_id", parameters, ids=ids)
def test_ctypes_gen(pyi_builder, monkeypatch, funcname, compiled_dylib,
                    test_id):
    # evaluate the soname here, so the test-code contains a constant.
    # We want the name of the dynamically-loaded library only, not its path.
    # See discussion in https://github.com/pyinstaller/pyinstaller/pull/1478#issuecomment-139622994.
    soname = compiled_dylib.basename

    source = """
Пример #3
0
            libfile = os.path.join(sys._MEIPASS, %(soname)r)
            print(libfile)
            assert os.path.isfile(libfile), '%(soname)s is missing'
            print('>>> file found')
    """

parameters = []
ids = []
for prefix in ('', 'ctypes.'):
    for funcname in  ('CDLL', 'PyDLL', 'WinDLL', 'OleDLL', 'cdll.LoadLibrary'):
        ids.append(prefix+funcname)
        params = (prefix+funcname, ids[-1])
        # Marking doesn't seem to chain here, so select just one skippping mark
        # instead of both.
        if not has_compiler:
            params = skipif_no_compiler(params)
        elif funcname in ("WinDLL", "OleDLL"):
            # WinDLL, OleDLL only work on windows.
            params = skipif_notwin(params)
        parameters.append(params)

@pytest.mark.parametrize("funcname,test_id", parameters, ids=ids)
def test_ctypes_gen(pyi_builder, monkeypatch, funcname, compiled_dylib, test_id):
    # evaluate the soname here, so the test-code contains a constant.
    # We want the name of the dynamically-loaded library only, not its path.
    # See discussion in https://github.com/pyinstaller/pyinstaller/pull/1478#issuecomment-139622994.
    soname = compiled_dylib.basename

    source = """
        import ctypes ; from ctypes import *
        lib = %s(%%(soname)r)