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

Python helpers.assert_equals函数代码示例

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

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



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

def test_activate_has_extra_env_vars(shell):
    """Test that environment variables in activate.d show up when activated"""
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        env_dirs=gen_test_env_paths(envs, shell)
        act_path = shells[shell]["path_from"](join(env_dirs[0], "etc", "conda", "activate.d"))
        deact_path = shells[shell]["path_from"](join(env_dirs[0], "etc", "conda", "deactivate.d"))
        os.makedirs(act_path)
        os.makedirs(deact_path)
        with open(join(act_path, "test" + shells[shell]["env_script_suffix"]), "w") as f:
            f.write(shells[shell]["set_var"] + "TEST_VAR=test\n")
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}"
        {echo} {var}
        """).format(envs=envs, env_dirs=env_dirs, var=shells[shell]["var_format"].format("TEST_VAR"), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, u'test', stderr)

        # Make sure the variable is reset after deactivation
        with open(join(deact_path, "test" + shells[shell]["env_script_suffix"]), "w") as f:
            f.write(shells[shell]["set_var"] + "TEST_VAR=\n")
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}"
        {source} "{env_dirs[0]}{cmd_path}deactivate"
        {echo} {var}
        """).format(envs=envs, env_dirs=env_dirs, var=shells[shell]["var_format"].format("TEST_VAR"), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, u'', stderr)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:28,代码来源:test_activate.py


示例3: test_activate_deactivate

def test_activate_deactivate(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:

        # debug TODO: remove
        if shell == 'bash.exe':
            commands = (shell_vars['command_setup'] + """
            env | sort
            {source} "{syspath}{binpath}activate" "{env_dirs[0]}" {nul}
            env | sort
            set -x
            {source} "{syspath}{binpath}deactivate"
            env | sort
            {printpath}
            """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **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" "{env_dirs[0]}" {nul}
        {source} "{syspath}{binpath}deactivate"
        {printpath}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **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,代码行数:34,代码来源:test_activate.py


示例4: test_activate_has_extra_env_vars

def test_activate_has_extra_env_vars(shell):
    """Test that environment variables in activate.d show up when activated"""
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        env_dirs=gen_test_env_paths(envs, shell)
        for path in ["activate", "deactivate"]:
            dir = os.path.join(shells[shell]['path_from'](env_dirs[0]), "etc", "conda", "%s.d" % path)
            os.makedirs(dir)
            file = os.path.join(dir, "test" + shells[shell]["env_script_suffix"])
            setting = "test" if path == "activate" else ""
            with open(file, 'w') as f:
                f.write(shells[shell]["set_var"] + "TEST_VAR=%s\n" % setting)
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{binpath}activate" "{env_dirs[0]}"
        {echo} {var}
        """).format(envs=envs, env_dirs=env_dirs, var=shells[shell]["var_format"].format("TEST_VAR"), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, u'test', stderr)

        # Make sure the variable is reset after deactivation

        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{binpath}activate" "{env_dirs[0]}"
        {source} "{env_dirs[0]}{binpath}deactivate"
        {echo} {var}.
        """).format(envs=envs, env_dirs=env_dirs, var=shells[shell]["var_format"].format("TEST_VAR"), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        # period here is because when var is blank, windows prints out the current echo setting.
        assert_equals(stdout, u'.', stderr)
开发者ID:happy-fish,项目名称:conda,代码行数:29,代码来源:test_activate.py


示例5: test_activate_relative_path

def test_activate_relative_path(shell):
    """
    current directory should be searched for environments
    """
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        env_dirs = gen_test_env_paths(envs, shell)
        env_dir = os.path.basename(env_dirs[0])
        work_dir = os.path.dirname(env_dir)
        commands = (shell_vars['command_setup'] + """
        cd {work_dir}
        {source} "{syspath}{binpath}activate" "{env_dir}"
        {printdefaultenv}
        """).format(work_dir=envs, envs=envs, env_dir=env_dir, **shell_vars)
        cwd = os.getcwd()
        # this is not effective for running bash on windows.  It starts
        #    in your home dir no matter what.  That's what the cd is for above.
        os.chdir(envs)
        try:
            stdout, stderr = run_in(commands, shell, cwd=envs)
        except:
            raise
        finally:
            os.chdir(cwd)
        assert_equals(stdout.rstrip(), env_dir, stderr)
开发者ID:happy-fish,项目名称:conda,代码行数:25,代码来源:test_activate.py


示例6: test_activate_non_ascii_char_in_path

def test_activate_non_ascii_char_in_path(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='Ånvs', dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{binpath}activate" "{env_dirs[0]}"
        {source} "{env_dirs[0]}{binpath}deactivate"
        {printdefaultenv}.
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, u'.', stderr)
开发者ID:happy-fish,项目名称:conda,代码行数:10,代码来源:test_activate.py


示例7: test_activate_bad_directory

def test_activate_bad_directory(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[2]}"
        {printpath}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_not_in(shells[shell]["path_to"](_envpaths(envs, 'test3')[0]), stdout)
        assert_equals(stderr, u'Error: could not find environment: {envpaths3}'.format(envpaths3=_envpaths(envs, 'test3')[0]))
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:11,代码来源:test_activate.py


示例8: test_wrong_args

def test_wrong_args(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" two args
        {printpath}
        """).format(envs=envs, **shell_vars)

        stdout, stderr = run_in(commands, shell)
        assert_equals(stderr, u'Error: did not expect more than one argument.')
        assert_equals(stdout, shell_vars['base_path'], stderr)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:11,代码来源:test_activate.py


示例9: test_deactivate_from_env

def test_deactivate_from_env(shell):
    """Tests whether the deactivate bat file or link in the activated environment works OK"""
    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]}"
        {source} "{env_dirs[0]}{binpath}deactivate"
        {printdefaultenv}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, u'', stderr)
开发者ID:happy-fish,项目名称:conda,代码行数:11,代码来源:test_activate.py


示例10: test_activate_deactivate

def test_activate_deactivate(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}deactivate"
        {printpath}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)

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


示例11: test_activate_non_ascii_char_in_path

def test_activate_non_ascii_char_in_path(shell):
    if shell.lower() not in ["cmd.exe", "powershell"]:
        pytest.xfail("subprocess with python 2.7 is broken with unicode")
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='Ånvs', dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}"
        {source} "{env_dirs[0]}{cmd_path}deactivate"
        {printdefaultenv}
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, u'', stderr)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:12,代码来源:test_activate.py


示例12: 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


示例13: 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


示例14: test_activate_from_env

def test_activate_from_env(shell):
    """Tests whether the activate bat file or link in the activated environment works OK"""
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        env_dirs=gen_test_env_paths(envs, shell)
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{binpath}activate" "{env_dirs[0]}"
        {source} "{env_dirs[0]}{binpath}activate" "{env_dirs[1]}"
        {printdefaultenv}
        """).format(envs=envs, env_dirs=env_dirs, **shell_vars)
        stdout, stderr = run_in(commands, shell)
        # rstrip on output is because the printing to console picks up an extra space
        assert_equals(stdout.rstrip(), env_dirs[1], stderr)
开发者ID:happy-fish,项目名称:conda,代码行数:13,代码来源:test_activate.py


示例15: test_activate_does_not_leak_echo_setting

def test_activate_does_not_leak_echo_setting(shell):
    """Test that activate's setting of echo to off does not disrupt later echo calls"""
    if not on_win or shell != "cmd.exe":
        pytest.skip("test only relevant for cmd.exe on win")
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs:
        commands = (shell_vars['command_setup'] + """
        @echo on
        @call "{syspath}{binpath}activate.bat" "{env_dirs[0]}"
        @echo
        """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars)
        stdout, stderr = run_in(commands, shell)
        assert_equals(stdout, u'ECHO is on.', stderr)
开发者ID:njalerikson,项目名称:conda,代码行数:13,代码来源:test_activate.py


示例16: 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


示例17: 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


示例18: test_activate_relative_path

def test_activate_relative_path(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
        start_dir = os.getcwd()
        env_dirs = gen_test_env_paths(envs, shell)
        os.chdir(envs)
        env_dir = os.path.basename(env_dirs[0])
        commands = (shell_vars['command_setup'] + """
        {source} "{syspath}{cmd_path}activate" "{env_dir}"
        {printdefaultenv}
        """).format(envs=envs, env_dir=env_dir, **shell_vars)
        stdout, stderr = run_in(commands, shell)
        os.chdir(start_dir)
        assert_equals(stdout, u'{env_dirs[0]}'.format(envs=envs, env_dirs=env_dirs), stderr)
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:14,代码来源:test_activate.py


示例19: test_path_translation

def test_path_translation():
    test_cygwin_path = "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_unix_path = "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_win_path = "test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text"
    assert_equals(test_win_path, unix_path_to_win(test_unix_path))
    assert_equals(test_unix_path, win_path_to_unix(test_win_path))
    assert_equals(test_cygwin_path, win_path_to_cygwin(test_win_path))
    assert_equals(test_win_path, cygwin_path_to_win(test_cygwin_path))
开发者ID:ZachDZimmerman,项目名称:conda,代码行数:8,代码来源:test_activate.py


示例20: test_wrong_args

def test_wrong_args(shell):
    shell_vars = _format_vars(shell)
    with TemporaryDirectory(prefix="envs", 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_equals(stderr, u"Error: did not expect more than one argument.\n    (got two args)")
        assert_equals(stdout, shell_vars["base_path"], stderr)
开发者ID:jaimergp,项目名称:conda,代码行数:15,代码来源:test_activate.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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