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

Python helpers.assert_in函数代码示例

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

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



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

示例1: test_activate_root

def test_activate_root(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs:
        commands = (
            shell_vars["command_setup"]
            + """
        {source} "{syspath}{binpath}activate" root
        {printpath}
        """
        ).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_in(shells[shell]["pathsep"].join(_envpaths(root_dir, shelldict=shells[shell])), stdout, stderr)

        commands = (
            shell_vars["command_setup"]
            + """
        {source} "{syspath}{binpath}activate" root
        {source} "{syspath}{binpath}deactivate"
        {printpath}
        """
        ).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        stdout = strip_leading_library_bin(stdout, shells[shell])
        assert_equals(stdout, u"%s" % shell_vars["base_path"], stderr)
开发者ID:jaimergp,项目名称:conda,代码行数:26,代码来源:test_activate.py


示例2: test_activate_bad_env_keeps_existing_good_env

def test_activate_bad_env_keeps_existing_good_env(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} {syspath}{binpath}activate "{env_dirs[0]}" {nul}
        {source} "{syspath}{binpath}activate" "{env_dirs[2]}"
        {printpath}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_in(shells[shell]['pathsep'].join(_envpaths(envs, 'test 1', shelldict=shells[shell])),stdout)
开发者ID:happy-fish,项目名称:conda,代码行数:11,代码来源:test_activate.py


示例3: test_activate_test1

def test_activate_test1(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate{shell_suffix}" "{env_dirs[0]}"
        {printpath}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_equals(stderr, u'prepending {envpaths} to PATH'\
                        .format(envpaths=pathlist_to_str(_envpaths(envs, 'test1'), False)), shell)
        assert_in(pathsep.join(_envpaths(envs, 'test1')), shells[shell]["path_from"](stdout), shell)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:12,代码来源:test_activate.py


示例4: test_activate_test1

def test_activate_test1(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs:
        commands = (
            shell_vars["command_setup"]
            + """
        {source} "{syspath}{binpath}activate{shell_suffix}" "{env_dirs[0]}"
        {printpath}
        """
        ).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_in(shells[shell]["pathsep"].join(_envpaths(envs, "test 1", shelldict=shells[shell])), stdout, shell)
开发者ID:jaimergp,项目名称:conda,代码行数:13,代码来源:test_activate.py


示例5: test_activate_bad_env_keeps_existing_good_env

def test_activate_bad_env_keeps_existing_good_env(shell):
    if shell == 'bash.exe':
        pytest.skip("usage of cygpath in win_path_to_unix messes this test up")
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} {syspath}{binpath}activate "{env_dirs[0]}" {nul}
        {source} "{syspath}{binpath}activate" "{env_dirs[3]}"
        {printpath}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_in(shells[shell]['pathsep'].join(_envpaths(envs, 'test 1', shell)), stdout)
开发者ID:njalerikson,项目名称:conda,代码行数:13,代码来源:test_activate.py


示例6: test_activate_env_from_env_with_root_activate

def test_activate_env_from_env_with_root_activate(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{binpath}activate" "{env_dirs[0]}" {nul}
        {source} "{syspath}{binpath}activate" "{env_dirs[1]}"
        {printpath}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_equals(stderr, u'prepending {envpaths2} to PATH'\
            .format(envpaths2=pathlist_to_str(_envpaths(envs, 'test 2', shelldict=shells[shell]))))
        assert_in(shells[shell]['pathsep'].join(_envpaths(envs, 'test 2', shelldict=shells[shell])), stdout)
开发者ID:AnddyWang,项目名称:conda,代码行数:13,代码来源:test_activate.py


示例7: test_activate_help

def test_activate_help(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs:
        if shell not in ["powershell.exe", "cmd.exe"]:
            commands = (
                shell_vars["command_setup"]
                + """
            "{syspath}{binpath}activate" Zanzibar
            """
            ).format(envs=envs, **shell_vars)
            stdout, stderr = run_in(commands, shell)
            assert_equals(stdout, "")
            assert_in("activate must be sourced", stderr)
            # assert_in("Usage: source activate ENV", stderr)

        commands = (
            shell_vars["command_setup"]
            + """
        {source} "{syspath}{binpath}activate" --help
        """
        ).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, "")

        if shell in ["cmd.exe", "powershell"]:
            # assert_in("Usage: activate ENV", stderr)
            pass
        else:
            # assert_in("Usage: source activate ENV", stderr)

            commands = (
                shell_vars["command_setup"]
                + """
            {syspath}{binpath}deactivate
            """
            ).format(envs=envs, **shell_vars)
            stdout, stderr = run_in(commands, shell)
            assert_equals(stdout, "")
            assert_in("deactivate must be sourced", stderr)
            # assert_in("Usage: source deactivate", stderr)

        commands = (
            shell_vars["command_setup"]
            + """
        {source} {syspath}{binpath}deactivate --help
        """
        ).format(envs=envs, **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, "")
开发者ID:jaimergp,项目名称:conda,代码行数:50,代码来源:test_activate.py


示例8: test_activate_root_env_from_other_env

def test_activate_root_env_from_other_env(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}" {nul}
        {source} "{syspath}{cmd_path}activate" root
        {printpath}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_in(shells[shell]["path_to"](pathsep.join(_envpaths(root_dir))),
                  stdout)
        assert_not_in(shells[shell]["path_to"](pathsep.join(_envpaths(envs, 'test1'))),
                      stdout)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:14,代码来源:test_activate.py


示例9: test_wrong_args

def test_wrong_args(shell):
    if shell == 'bash.exe':
        pytest.skip("usage of cygpath in win_path_to_unix messes this test up")
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{binpath}activate" two args
        {printpath}
        """).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        stdout = strip_leading_library_bin(stdout, shells[shell])
        assert_in("activate does not accept more than one argument", stderr)
        assert_equals(stdout, shell_vars['base_path'], stderr)
开发者ID:njalerikson,项目名称:conda,代码行数:14,代码来源:test_activate.py


示例10: test_activate_symlinking

def test_activate_symlinking(shell):
    """Symlinks or bat file redirects are created at activation time.  Make sure that the
    files/links exist, and that they point where they should."""
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}"
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stderr, u'prepending {envpaths1} to PATH'\
                .format(syspath=pathlist_to_str(_envpaths(root_dir)),
                        envpaths1=pathlist_to_str(_envpaths(envs, 'test1'))))

        where = 'Scripts' if sys.platform == 'win32' else 'bin'
        for env in gen_test_env_paths(envs, shell)[:2]:
            scripts = {where: ["conda"],
                        'cmd': ["activate", "deactivate"],
            }
            for where, files in scripts.items():
                for f in files:
                    if sys.platform == "win32":
                        file_path = shells[shell]["slash_convert"][1].join([env, where, f + shells[shell]["shell_suffix"]])
                        # must translate path to windows representation for Python's sake
                        file_path = shells[shell]["path_from"](file_path)
                        assert(os.path.lexists(file_path))
                    else:
                        file_path = join(env, where, f)
                        assert(os.path.lexists(file_path))
                        s = os.lstat(file_path)
                        assert(stat.S_ISLNK(s.st_mode))
                        assert(os.readlink(file_path) == '{root_path}'.format(root_path=join(sys.prefix, where, f)))

        if platform != 'win':
            # Test activate when there are no write permissions in the
            # env.
            prefix_bin_path = join(gen_test_env_paths(envs, shell)[2], 'bin')
            commands = (shell_vars['command_setup'] + """
            mkdir -p {prefix_bin_path}
            chmod 000 {prefix_bin_path}
            {source} activate "{env_dirs[2]}"
            """).format(prefix_bin_path=prefix_bin_path, envs=envs,
                                env_dirs=gen_test_env_paths(envs, shell),
                **shell_vars)
            stdout, stderr = run_in(commands, shell)
            assert_in("do not have write access", stderr)

            # restore permissions so the dir will get cleaned up
            run_in("chmod 777 {prefix_bin_path}".format(prefix_bin_path=prefix_bin_path), shell)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:48,代码来源:test_activate.py


示例11: test_activate_root

def test_activate_root(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" root
        {printpath}
        """).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_in(shells[shell]["path_to"](pathsep.join(_envpaths(root_dir))), stdout)

        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" root
        {source} "{syspath}{cmd_path}deactivate"
        {printpath}
        """).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, u"%s" % shell_vars['base_path'], stderr)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:19,代码来源:test_activate.py


示例12: test_activate_root_simple

def test_activate_root_simple(shell):
    if shell == 'bash.exe':
        pytest.skip("usage of cygpath in win_path_to_unix messes this test up")
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{binpath}activate" root
        {printpath}
        """).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_in(shells[shell]['pathsep'].join(_envpaths(context.root_prefix, shell=shell)), stdout, stderr)
        assert not stderr

        # debug TODO: remove
        if shell == 'bash.exe':
            commands = (shell_vars['command_setup'] + """
            env | sort
            {source} "{syspath}{binpath}activate" root
            env | sort
            echo {source} "{syspath}{binpath}deactivate"
            {source} "{syspath}{binpath}deactivate"
            env | sort
            {printpath}
            """).format(envs=envs, **shell_vars)
            stdout, stderr = run_in(commands, shell)
            sys.stdout.write(stdout)
            sys.stderr.write(stderr)


        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{binpath}activate" root
        {source} "{syspath}{binpath}deactivate"
        {printpath}
        """).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert not stderr
        stdout = strip_leading_library_bin(stdout, shells[shell])
        assert_equals(stdout, u'%s' % shell_vars['base_path'])
开发者ID:njalerikson,项目名称:conda,代码行数:40,代码来源:test_activate.py


示例13: test_activate_symlinking

def test_activate_symlinking(shell):
    """Symlinks or bat file redirects are created at activation time.  Make sure that the
    files/links exist, and that they point where they should."""
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs:
        where = "Scripts" if on_win else "bin"
        for env in gen_test_env_paths(envs, shell)[:2]:
            scripts = ["conda", "activate", "deactivate"]
            for f in scripts:
                if on_win:
                    file_path = os.path.join(env, where, f + shells[shell]["shell_suffix"])
                    # must translate path to windows representation for Python's sake
                    file_path = shells[shell]["path_from"](file_path)
                    assert os.path.lexists(file_path)
                else:
                    file_path = os.path.join(env, where, f)
                    assert os.path.lexists(file_path)
                    s = os.lstat(file_path)
                    assert stat.S_ISLNK(s.st_mode)
                    assert os.readlink(file_path) == "{root_path}".format(root_path=os.path.join(sys.prefix, where, f))

        if platform != "win":
            # Test activate when there are no write permissions in the
            # env.
            prefix_bin_path = os.path.join(gen_test_env_paths(envs, shell)[2], "bin")
            commands = (
                shell_vars["command_setup"]
                + """
            mkdir -p "{prefix_bin_path}"
            chmod 444 "{prefix_bin_path}"
            {source} activate "{env_dirs[2]}"
            """
            ).format(prefix_bin_path=prefix_bin_path, envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)
            stdout, stderr = run_in(commands, shell)
            assert_in("not have write access", stderr)

            # restore permissions so the dir will get cleaned up
            run_in('chmod 777 "{prefix_bin_path}"'.format(prefix_bin_path=prefix_bin_path), shell)
开发者ID:jaimergp,项目名称:conda,代码行数:38,代码来源:test_activate.py


示例14: test_info

def test_info():
    conda_info_out, conda_info_err, rc = run_command(Commands.INFO)
    assert_equals(conda_info_err, '')
    for name in ['platform', 'conda version',
                 'envs directories', 'package cache',
                 'channel URLs', 'config file', 'offline mode']:
        assert_in(name, conda_info_out)

    conda_info_e_out, conda_info_e_err, rc = run_command(Commands.INFO, '-e')
    assert_in('base', conda_info_e_out)
    assert_equals(conda_info_e_err, '')

    conda_info_s_out, conda_info_s_err, rc = run_command(Commands.INFO, '-s')
    assert_equals(conda_info_s_err, '')
    for name in ['sys.version', 'sys.prefix', 'sys.executable', 'conda location',
                 'conda-build', 'PATH']:
        assert_in(name, conda_info_s_out)

    conda_info_all_out, conda_info_all_err, rc = run_command(Commands.INFO, '--all')
    assert_equals(conda_info_all_err, '')
    assert_in(conda_info_out, conda_info_all_out)
    assert_in(conda_info_e_out, conda_info_all_out)
    assert_in(conda_info_s_out, conda_info_all_out)
开发者ID:alanhdu,项目名称:conda,代码行数:23,代码来源:test_info.py


示例15: test_info

def test_info():
    conda_info_out, conda_info_err = run_conda_command('info')
    assert_equals(conda_info_err, '')
    for name in ['platform', 'conda version', 'root environment',
        'default environment', 'envs directories', 'package cache',
        'channel URLs', 'config file', 'is foreign system']:
        assert_in(name, conda_info_out)

    conda_info_e_out, conda_info_e_err = run_conda_command('info', '-e')
    assert_in('root', conda_info_e_out)
    assert_equals(conda_info_e_err, '')

    conda_info_s_out, conda_info_s_err = run_conda_command('info', '-s')
    assert_equals(conda_info_s_err, '')
    for name in ['sys.version', 'sys.prefix', 'sys.executable', 'conda location',
        'conda-build', 'CIO_TEST', 'CONDA_DEFAULT_ENV', 'PATH', 'PYTHONPATH']:
        assert_in(name, conda_info_s_out)
    if config.platform == 'linux':
        assert_in('LD_LIBRARY_PATH', conda_info_s_out)
    if config.platform == 'osx':
        assert_in('DYLD_LIBRARY_PATH', conda_info_s_out)

    conda_info_all_out, conda_info_all_err = run_conda_command('info', '--all')
    assert_equals(conda_info_all_err, '')
    assert_in(conda_info_out, conda_info_all_out)
    assert_in(conda_info_e_out, conda_info_all_out)
    assert_in(conda_info_s_out, conda_info_all_out)
开发者ID:AnddyWang,项目名称:conda,代码行数:27,代码来源:test_info.py


示例16: test_activate_help

def test_activate_help(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        if not platform.startswith("win"):
            commands = (shell_vars['command_setup'] + """
            "{syspath}{cmd_path}activate" Zanzibar
            """).format(envs=envs, **shell_vars)
            stdout, stderr = run_in(commands, shell)
            assert_equals(stdout, '')
            assert_in("activate must be sourced", stderr)
            assert_in("Usage: source activate ENV", stderr)

        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" --help
        """).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, '')
        if platform.startswith("win") and shell in ["cmd.exe", "powershell"]:
            assert_in("Usage: activate ENV", stderr)
        else:
            assert_in("Usage: source activate ENV", stderr)

            commands = (shell_vars['command_setup'] + """
            {syspath}{cmd_path}deactivate
            """).format(envs=envs, **shell_vars)
            stdout, stderr = run_in(commands, shell)
            assert_equals(stdout, '')
            assert_in("deactivate must be sourced", stderr)
            assert_in("Usage: source deactivate", stderr)

        commands = (shell_vars['command_setup'] + """
        {source} {syspath}{cmd_path}deactivate --help
        """).format(envs=envs, **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, '')
        if platform == 'win' and shell in ["cmd.exe", "powershell"]:
            assert_in("Usage: deactivate", stderr)
        else:
            assert_in("Usage: source deactivate", stderr)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:40,代码来源:test_activate.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python helpers.capture_json_with_argv函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.assert_equals函数代码示例发布时间: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