当前位置: 首页>>代码示例>>Python>>正文


Python helpers.assert_equals函数代码示例

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


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


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