• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python udir.join函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中testing.udir.udir.join函数的典型用法代码示例。如果您正苦于以下问题:Python join函数的具体用法?Python join怎么用?Python join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了join函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setup_class

 def setup_class(cls):
     from testing.udir import udir
     udir.join('testownlib.c').write(SOURCE)
     subprocess.check_call(
         'gcc testownlib.c -shared -fPIC -o testownlib.so',
         cwd=str(udir), shell=True)
     cls.module = str(udir.join('testownlib.so'))
开发者ID:AN2016,项目名称:ffi,代码行数:7,代码来源:test_ownlib.py


示例2: test_verifier_args

 def test_verifier_args(self):
     ffi = FFI()
     ffi.cdef("double sin(double x);")
     csrc = '/*hi there %s!4*/#include "test_verifier_args.h"\n' % self
     udir.join('test_verifier_args.h').write('#include <math.h>\n')
     v = Verifier(ffi, csrc, include_dirs=[str(udir)],
                  force_generic_engine=self.generic)
     library = v.load_library()
     assert library.sin(12.3) == math.sin(12.3)
开发者ID:mandriva-management-console,项目名称:pulse-on-univention,代码行数:9,代码来源:test_zdistutils.py


示例3: really_run_setup_and_program

def really_run_setup_and_program(dirname, venv_dir_and_paths, python_snippet):
    venv_dir, paths = venv_dir_and_paths
    def remove(dir):
        dir = str(SNIPPET_DIR.join(dirname, dir))
        shutil.rmtree(dir, ignore_errors=True)
    remove('build')
    remove('__pycache__')
    for basedir in os.listdir(str(SNIPPET_DIR.join(dirname))):
        remove(os.path.join(basedir, '__pycache__'))
    olddir = os.getcwd()
    python_f = udir.join('x.py')
    python_f.write(py.code.Source(python_snippet))
    try:
        os.chdir(str(SNIPPET_DIR.join(dirname)))
        if os.name == 'nt':
            bindir = 'Scripts'
        else:
            bindir = 'bin'
        vp = str(venv_dir.join(bindir).join('python'))
        env = os.environ.copy()
        env['PYTHONPATH'] = paths
        subprocess.check_call((vp, 'setup.py', 'clean'), env=env)
        subprocess.check_call((vp, 'setup.py', 'install'), env=env)
        subprocess.check_call((vp, str(python_f)), env=env)
    finally:
        os.chdir(olddir)
开发者ID:chevah,项目名称:python-package,代码行数:26,代码来源:test_zintegration.py


示例4: create_venv

def create_venv(name):
    tmpdir = udir.join(name)
    try:
        subprocess.check_call(['virtualenv', '--distribute',
                               '-p', os.path.abspath(sys.executable),
                               str(tmpdir)])
    except OSError as e:
        py.test.skip("Cannot execute virtualenv: %s" % (e,))

    site_packages = None
    for dirpath, dirnames, filenames in os.walk(str(tmpdir)):
        if os.path.basename(dirpath) == 'site-packages':
            site_packages = dirpath
            break
    if site_packages:
        try:
            from cffi import _pycparser
            modules = ('cffi', '_cffi_backend')
        except ImportError:
            modules = ('cffi', '_cffi_backend', 'pycparser')
            try:
                import ply
            except ImportError:
                pass
            else:
                modules += ('ply',)   # needed for older versions of pycparser
        for module in modules:
            target = imp.find_module(module)[1]
            os.symlink(target, os.path.join(site_packages,
                                            os.path.basename(target)))
    return tmpdir
开发者ID:CThaw90,项目名称:SDNHeaderAuthentication,代码行数:31,代码来源:test_zintegration.py


示例5: test_invalid_dotdotdot_in_macro

def test_invalid_dotdotdot_in_macro():
    ffi = FFI()
    ffi.cdef("#define FOO ...")
    target = udir.join('test_invalid_dotdotdot_in_macro.py')
    e = py.test.raises(VerificationError, make_py_source, ffi,
                       'test_invalid_dotdotdot_in_macro', str(target))
    assert str(e.value) == ("macro FOO: cannot use the syntax '...' in "
                            "'#define FOO ...' when using the ABI mode")
开发者ID:NilStack,项目名称:SwiftKitten,代码行数:8,代码来源:test_dlopen.py


示例6: test_no_cross_include

def test_no_cross_include():
    baseffi = FFI()
    baseffi.set_source('test_no_cross_include_base', "..source..")
    #
    ffi = FFI()
    ffi.include(baseffi)
    target = udir.join('test_no_cross_include.py')
    py.test.raises(VerificationError, make_py_source,
                   ffi, 'test_no_cross_include', str(target))
开发者ID:NilStack,项目名称:SwiftKitten,代码行数:9,代码来源:test_dlopen.py


示例7: setup_method

 def setup_method(self, meth):
     self.executable = os.path.abspath(sys.executable)
     self.rootdir = os.path.abspath(os.path.dirname(os.path.dirname(
         cffi.__file__)))
     self.udir = udir.join(meth.__name__)
     os.mkdir(str(self.udir))
     if meth.chdir_to_tmp:
         self.saved_cwd = os.getcwd()
         os.chdir(str(self.udir))
开发者ID:RBPI,项目名称:real-python-test,代码行数:9,代码来源:test_zdist.py


示例8: setup_module

def setup_module(mod):
    SRC = """
    #include <string.h>
    #define FOOBAR (-42)
    static const int FOOBAZ = -43;
    #define BIGPOS 420000000000L
    #define BIGNEG -420000000000L
    int add42(int x) { return x + 42; }
    int add43(int x, ...) { return x; }
    int globalvar42 = 1234;
    const int globalconst42 = 4321;
    const char *const globalconsthello = "hello";
    struct foo_s;
    typedef struct bar_s { int x; signed char a[]; } bar_t;
    enum foo_e { AA, BB, CC };

    void init_test_re_python(void) { }      /* windows hack */
    void PyInit__test_re_python(void) { }   /* windows hack */
    """
    tmpdir = udir.join('test_re_python')
    tmpdir.ensure(dir=1)
    c_file = tmpdir.join('_test_re_python.c')
    c_file.write(SRC)
    ext = ffiplatform.get_extension(
        str(c_file),
        '_test_re_python',
        export_symbols=['add42', 'add43', 'globalvar42',
                        'globalconst42', 'globalconsthello']
    )
    outputfilename = ffiplatform.compile(str(tmpdir), ext)
    mod.extmod = outputfilename
    mod.tmpdir = tmpdir
    #
    ffi = FFI()
    ffi.cdef("""
    #define FOOBAR -42
    static const int FOOBAZ = -43;
    #define BIGPOS 420000000000L
    #define BIGNEG -420000000000L
    int add42(int);
    int add43(int, ...);
    int globalvar42;
    const int globalconst42;
    const char *const globalconsthello = "hello";
    int no_such_function(int);
    int no_such_globalvar;
    struct foo_s;
    typedef struct bar_s { int x; signed char a[]; } bar_t;
    enum foo_e { AA, BB, CC };
    int strlen(const char *);
    """)
    ffi.set_source('re_python_pysrc', None)
    ffi.emit_python_code(str(tmpdir.join('re_python_pysrc.py')))
    mod.original_ffi = ffi
    #
    sys.path.insert(0, str(tmpdir))
开发者ID:Piotrek321,项目名称:Voice,代码行数:56,代码来源:test_re_python.py


示例9: test_struct_included

def test_struct_included():
    baseffi = FFI()
    baseffi.cdef("struct foo_s { int x; };")
    baseffi.set_source('test_struct_included_base', None)
    #
    ffi = FFI()
    ffi.include(baseffi)
    target = udir.join('test_struct_included.py')
    make_py_source(ffi, 'test_struct_included', str(target))
    assert target.read() == r"""# auto-generated file
开发者ID:NilStack,项目名称:SwiftKitten,代码行数:10,代码来源:test_dlopen.py


示例10: test_constant_of_value_unknown_to_the_compiler

def test_constant_of_value_unknown_to_the_compiler():
    extra_c_source = udir.join(
        'extra_test_constant_of_value_unknown_to_the_compiler.c')
    extra_c_source.write('const int external_foo = 42;\n')
    ffi = FFI()
    ffi.cdef("const int external_foo;")
    lib = verify(ffi, 'test_constant_of_value_unknown_to_the_compiler', """
        extern const int external_foo;
    """, sources=[str(extra_c_source)])
    assert lib.external_foo == 42
开发者ID:RBPI,项目名称:real-python-test,代码行数:10,代码来源:test_recompiler.py


示例11: test_write_source_explicit_filename

 def test_write_source_explicit_filename(self):
     ffi = FFI()
     ffi.cdef("double sin(double x);")
     csrc = '/*hi there %s!*/\n#include <math.h>\n' % self
     v = Verifier(ffi, csrc, force_generic_engine=self.generic)
     v.sourcefilename = filename = str(udir.join('write_source.c'))
     v.write_source()
     assert filename == v.sourcefilename
     with open(filename, 'r') as f:
         data = f.read()
     assert csrc in data
开发者ID:mandriva-management-console,项目名称:pulse-on-univention,代码行数:11,代码来源:test_zdistutils.py


示例12: test_include

def test_include():
    ffi = FFI()
    ffi.cdef("#define ABC 123")
    ffi.set_source('test_include', None)
    target = udir.join('test_include.py')
    make_py_source(ffi, 'test_include', str(target))
    assert target.read() == r"""# auto-generated file
import _cffi_backend

ffi = _cffi_backend.FFI('test_include',
    _version = 0x2601,
    _types = b'',
    _globals = (b'\xFF\xFF\xFF\x1FABC',123,),
)
"""
    #
    ffi2 = FFI()
    ffi2.include(ffi)
    target2 = udir.join('test2_include.py')
    make_py_source(ffi2, 'test2_include', str(target2))
    assert target2.read() == r"""# auto-generated file
开发者ID:NilStack,项目名称:SwiftKitten,代码行数:21,代码来源:test_dlopen.py


示例13: setup_class

 def setup_class(cls):
     cls.module = None
     from testing.udir import udir
     udir.join('testownlib.c').write(SOURCE)
     if sys.platform == 'win32':
         import os
         # did we already build it?
         if os.path.exists(str(udir.join('testownlib.dll'))):
             cls.module = str(udir.join('testownlib.dll'))
             return
         # try (not too hard) to find the version used to compile this python
         # no mingw
         from distutils.msvc9compiler import get_build_version
         version = get_build_version()
         toolskey = "VS%0.f0COMNTOOLS" % version
         toolsdir = os.environ.get(toolskey, None)
         if toolsdir is None:
             return
         productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC")
         productdir = os.path.abspath(productdir)
         vcvarsall = os.path.join(productdir, "vcvarsall.bat")
         # 64?
         arch = 'x86'
         if sys.maxsize > 2**32:
             arch = 'amd64'
         if os.path.isfile(vcvarsall):
             cmd = '"%s" %s' % (vcvarsall, arch) + ' & cl.exe testownlib.c ' \
                     ' /LD /Fetestownlib.dll'
             subprocess.check_call(cmd, cwd = str(udir), shell=True)    
             cls.module = str(udir.join('testownlib.dll'))
     else:
         subprocess.check_call(
             'cc testownlib.c -shared -fPIC -o testownlib.so',
             cwd=str(udir), shell=True)
         cls.module = str(udir.join('testownlib.so'))
开发者ID:tharvik,项目名称:cffi,代码行数:35,代码来源:test_ownlib.py


示例14: test_compile_module_explicit_filename

 def test_compile_module_explicit_filename(self):
     ffi = FFI()
     ffi.cdef("double sin(double x);")
     csrc = '/*hi there %s!2*/\n#include <math.h>\n' % self
     v = Verifier(ffi, csrc, force_generic_engine=self.generic)
     basename = self.__class__.__name__ + 'test_compile_module'
     v.modulefilename = filename = str(udir.join(basename + '.so'))
     v.compile_module()
     assert filename == v.modulefilename
     assert v.get_module_name() == basename
     if v.generates_python_module():
         mod = imp.load_dynamic(v.get_module_name(), v.modulefilename)
         assert hasattr(mod, '_cffi_setup')
开发者ID:mandriva-management-console,项目名称:pulse-on-univention,代码行数:13,代码来源:test_zdistutils.py


示例15: create_venv

def create_venv(name):
    tmpdir = udir.join(name)
    try:
        subprocess.check_call(['virtualenv', '--distribute',
                               '-p', os.path.abspath(sys.executable),
                               str(tmpdir)])
    except OSError as e:
        py.test.skip("Cannot execute virtualenv: %s" % (e,))

    try:
        deepcopy = os.symlink
    except:
        import shutil, errno
        def deepcopy(src, dst):
            try:
                shutil.copytree(src, dst)
            except OSError as e:
                if e.errno in (errno.ENOTDIR, errno.EINVAL):
                    shutil.copy(src, dst)
                else:
                    print('got errno')
                    print(e.errno)
                    print('not')
                    print(errno.ENOTDIR)
                    raise

    site_packages = None
    for dirpath, dirnames, filenames in os.walk(str(tmpdir)):
        if os.path.basename(dirpath) == 'site-packages':
            site_packages = dirpath
            break
    if site_packages:
        try:
            from cffi import _pycparser
            modules = ('cffi', '_cffi_backend')
        except ImportError:
            modules = ('cffi', '_cffi_backend', 'pycparser')
            try:
                import ply
            except ImportError:
                pass
            else:
                modules += ('ply',)   # needed for older versions of pycparser
        for module in modules:
            target = imp.find_module(module)[1]
            deepcopy(target, os.path.join(site_packages,
                                            os.path.basename(target)))
    return tmpdir
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:48,代码来源:test_zintegration.py


示例16: test_fputs_custom_FILE

 def test_fputs_custom_FILE(self):
     if self.Backend is CTypesBackend:
         py.test.skip("FILE not supported with the ctypes backend")
     filename = str(udir.join('fputs_custom_FILE'))
     ffi = FFI(backend=self.Backend())
     ffi.cdef("int fputs(const char *, FILE *);")
     C = ffi.dlopen(None)
     with open(filename, 'wb') as f:
         f.write(b'[')
         C.fputs(b"hello from custom file", f)
         f.write(b'][')
         C.fputs(b"some more output", f)
         f.write(b']')
     with open(filename, 'rb') as f:
         res = f.read()
     assert res == b'[hello from custom file][some more output]'
开发者ID:NilStack,项目名称:SwiftKitten,代码行数:16,代码来源:test_function.py


示例17: test_install_and_reload_module

    def test_install_and_reload_module(self, targetpackage='', ext_package=''):
        KEY = repr(self)
        if not hasattr(os, 'fork'):
            py.test.skip("test requires os.fork()")

        if targetpackage:
            udir.ensure(targetpackage, dir=1).ensure('__init__.py')
        sys.path.insert(0, str(udir))

        def make_ffi(**verifier_args):
            ffi = FFI()
            ffi.cdef("/* %s, %s, %s */" % (KEY, targetpackage, ext_package))
            ffi.cdef("double test1iarm(double x);")
            csrc = "double test1iarm(double x) { return x * 42.0; }"
            lib = ffi.verify(csrc, force_generic_engine=self.generic,
                             ext_package=ext_package,
                             **verifier_args)
            return ffi, lib

        childpid = os.fork()
        if childpid == 0:
            # in the child
            ffi, lib = make_ffi()
            assert lib.test1iarm(1.5) == 63.0
            # "install" the module by moving it into udir (/targetpackage)
            if targetpackage:
                target = udir.join(targetpackage)
            else:
                target = udir
            shutil.move(ffi.verifier.modulefilename, str(target))
            os._exit(0)
        # in the parent
        _, status = os.waitpid(childpid, 0)
        if not (os.WIFEXITED(status) and os.WEXITSTATUS(status) == 0):
            raise AssertionError   # see error above in subprocess

        from cffi import ffiplatform
        prev_compile = ffiplatform.compile
        try:
            if targetpackage == ext_package:
                ffiplatform.compile = lambda *args: dont_call_me_any_more
            # won't find it in tmpdir, but should find it correctly
            # installed in udir
            ffi, lib = make_ffi()
            assert lib.test1iarm(0.5) == 21.0
        finally:
            ffiplatform.compile = prev_compile
开发者ID:CThaw90,项目名称:SDNHeaderAuthentication,代码行数:47,代码来源:test_zdistutils.py


示例18: test_extension_object_extra_sources

 def test_extension_object_extra_sources(self):
     ffi = FFI()
     ffi.cdef("double test1eoes(double x);")
     extra_source = str(udir.join('extension_extra_sources.c'))
     with open(extra_source, 'w') as f:
         f.write('double test1eoes(double x) { return x * 6.0; }\n')
     csrc = '/*9%s*/' % self + '''
     double test1eoes(double x);   /* or #include "extra_sources.h" */
     '''
     lib = ffi.verify(csrc, sources=[extra_source],
                      force_generic_engine=self.generic)
     assert lib.test1eoes(7.0) == 42.0
     v = ffi.verifier
     ext = v.get_extension()
     assert 'distutils.extension.Extension' in str(ext.__class__)
     assert ext.sources == [maybe_relative_path(v.sourcefilename),
                            extra_source]
     assert ext.name == v.get_module_name()
开发者ID:CThaw90,项目名称:SDNHeaderAuthentication,代码行数:18,代码来源:test_zdistutils.py


示例19: really_run_setup_and_program

def really_run_setup_and_program(dirname, venv_dir, python_snippet):
    def remove(dir):
        dir = str(SNIPPET_DIR.join(dirname, dir))
        shutil.rmtree(dir, ignore_errors=True)
    remove('build')
    remove('__pycache__')
    for basedir in os.listdir(str(SNIPPET_DIR.join(dirname))):
        remove(os.path.join(basedir, '__pycache__'))
    olddir = os.getcwd()
    python_f = udir.join('x.py')
    python_f.write(py.code.Source(python_snippet))
    try:
        os.chdir(str(SNIPPET_DIR.join(dirname)))
        vp = str(venv_dir.join('bin/python'))
        subprocess.check_call((vp, 'setup.py', 'clean'))
        subprocess.check_call((vp, 'setup.py', 'install'))
        subprocess.check_call((vp, str(python_f)))
    finally:
        os.chdir(olddir)
开发者ID:CThaw90,项目名称:SDNHeaderAuthentication,代码行数:19,代码来源:test_zintegration.py


示例20: create_venv

def create_venv(name):
    tmpdir = udir.join(name)
    try:
        subprocess.check_call(['virtualenv', 
            #'--never-download', <= could be added, but causes failures
            # in random cases on random machines
                               '-p', os.path.abspath(sys.executable),
                               str(tmpdir)])
    except OSError as e:
        py.test.skip("Cannot execute virtualenv: %s" % (e,))

    site_packages = None
    for dirpath, dirnames, filenames in os.walk(str(tmpdir)):
        if os.path.basename(dirpath) == 'site-packages':
            site_packages = dirpath
            break
    paths = ""
    if site_packages:
        try:
            from cffi import _pycparser
            modules = ('cffi', '_cffi_backend')
        except ImportError:
            modules = ('cffi', '_cffi_backend', 'pycparser')
            try:
                import ply
            except ImportError:
                pass
            else:
                modules += ('ply',)   # needed for older versions of pycparser
        paths = []
        for module in modules:
            target = __import__(module, None, None, [])
            if not hasattr(target, '__file__'):   # for _cffi_backend on pypy
                continue
            src = os.path.abspath(target.__file__)
            for end in ['__init__.pyc', '__init__.pyo', '__init__.py']:
                if src.lower().endswith(end):
                    src = src[:-len(end)-1]
                    break
            paths.append(os.path.dirname(src))
        paths = os.pathsep.join(paths)
    return tmpdir, paths
开发者ID:chevah,项目名称:python-package,代码行数:42,代码来源:test_zintegration.py



注:本文中的testing.udir.udir.join函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.assert_raises_exactly函数代码示例发布时间:2022-05-27
下一篇:
Python testifycompat.assert_equal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap