def test_install_conda_sh(self):
        with tempdir() as conda_prefix:
            target_path = join(conda_prefix, 'etc', 'profile.d', 'conda.sh')
            context.dev = False
            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.MODIFIED

            with open(target_path) as fh:
                created_file_contents = fh.read()

            from conda.activate import PosixActivator
            activator = PosixActivator()

            line0, line1, line2, line3, _, remainder = created_file_contents.split('\n', 5)
            assert line0 == "export CONDA_EXE='%s'" % activator.path_conversion(context.conda_exe)
            assert line1 == "export _CE_M=''"
            assert line2 == "export _CE_CONDA=''"
            assert line3.startswith("export CONDA_PYTHON_EXE=")

            with open(join(CONDA_PACKAGE_ROOT, 'shell', 'etc', 'profile.d', 'conda.sh')) as fh:
                original_contents = fh.read()
            assert remainder == original_contents

            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.NO_CHANGE
Example #2
0
    def test_install_conda_sh(self):
        with tempdir() as conda_prefix:
            target_path = join(conda_prefix, 'etc', 'profile.d', 'conda.sh')
            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.MODIFIED

            with open(target_path) as fh:
                created_file_contents = fh.read()

            if on_win:
                first_line, second_line, remainder = created_file_contents.split(
                    '\n', 2)
                assert first_line == "export CONDA_EXE=\"$(cygpath '%s')\"" % context.conda_exe
                assert second_line == "export CONDA_BAT=\"%s\"" % join(
                    context.conda_prefix, 'condabin', 'conda.bat')
            else:
                first_line, remainder = created_file_contents.split('\n', 1)
                assert first_line == 'export CONDA_EXE="%s"' % context.conda_exe

            with open(
                    join(CONDA_PACKAGE_ROOT, 'shell', 'etc', 'profile.d',
                         'conda.sh')) as fh:
                original_contents = fh.read()
            assert remainder == original_contents

            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.NO_CHANGE
Example #3
0
    def test_install_conda_sh(self):
        with tempdir() as conda_prefix:
            target_path = join(conda_prefix, 'etc', 'profile.d', 'conda.sh')
            context.dev = False
            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.MODIFIED

            with open(target_path) as fh:
                created_file_contents = fh.read()

            if on_win:
                line0, line1, line2, line3, remainder = created_file_contents.split('\n', 4)
                assert line0 == "export CONDA_EXE=\"$(cygpath '%s')\"" % context.conda_exe
                assert line1 == "export _CE_M=-m"
                assert line2 == "export _CE_CONDA=conda"
                assert line3 == "export CONDA_BAT=\"%s\"" % join(context.conda_prefix, 'condabin', 'conda.bat')
            else:
                line0, line1, line2, _, remainder = created_file_contents.split('\n', 4)
                assert line0 == "export CONDA_EXE='%s'" % context.conda_exe
                assert line1 == "export _CE_M=''"
                assert line2 == "export _CE_CONDA=''"

            with open(join(CONDA_PACKAGE_ROOT, 'shell', 'etc', 'profile.d', 'conda.sh')) as fh:
                original_contents = fh.read()
            assert remainder == original_contents

            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.NO_CHANGE
Example #4
0
    def test_install_conda_sh(self):
        with tempdir() as conda_prefix:
            target_path = join(conda_prefix, 'etc', 'profile.d', 'conda.sh')
            context.dev = False
            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.MODIFIED

            with open(target_path) as fh:
                created_file_contents = fh.read()

            from conda.activate import PosixActivator
            activator = PosixActivator()

            line0, line1, line2, line3, _, remainder = created_file_contents.split('\n', 5)
            assert line0 == "export CONDA_EXE='%s'" % activator.path_conversion(context.conda_exe)
            assert line1 == "export _CE_M=''"
            assert line2 == "export _CE_CONDA=''"
            assert line3.startswith("export CONDA_PYTHON_EXE=")

            with open(join(CONDA_PACKAGE_ROOT, 'shell', 'etc', 'profile.d', 'conda.sh')) as fh:
                original_contents = fh.read()
            assert remainder == original_contents

            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.NO_CHANGE
Example #5
0
    def test_install_conda_sh(self):
        with tempdir() as conda_prefix:
            target_path = join(conda_prefix, 'etc', 'profile.d', 'conda.sh')
            context.dev = False
            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.MODIFIED

            with open(target_path) as fh:
                created_file_contents = fh.read()

            line0, line1, line2, _, remainder = created_file_contents.split('\n', 4)
            assert line0 == "export CONDA_EXE='%s'" % context.conda_exe
            assert line1 == "export _CE_M=''"
            assert line2 == "export _CE_CONDA=''"

            with open(join(CONDA_PACKAGE_ROOT, 'shell', 'etc', 'profile.d', 'conda.sh')) as fh:
                original_contents = fh.read()
            assert remainder == original_contents

            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.NO_CHANGE
Example #6
0
    def test_install_conda_sh(self):
        with tempdir() as conda_prefix:
            target_path = join(conda_prefix, 'etc', 'profile.d', 'conda.sh')
            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.MODIFIED

            with open(target_path) as fh:
                created_file_contents = fh.read()

            first_line, remainder = created_file_contents.split('\n', 1)
            if on_win:
                assert first_line == "export CONDA_EXE=\"$(cygpath '%s')\"" % context.conda_exe
            else:
                assert first_line == 'export CONDA_EXE="%s"' % context.conda_exe

            with open(join(CONDA_PACKAGE_ROOT, 'shell', 'etc', 'profile.d', 'conda.sh')) as fh:
                original_contents = fh.read()
            assert remainder == original_contents

            result = install_conda_sh(target_path, conda_prefix)
            assert result == Result.NO_CHANGE