Skip to content

Commit

Permalink
Remove outdated test (conda#11469)
Browse files Browse the repository at this point in the history
test_init_dev_and_NoBaseEnvironmentError is related to conda v 4.5 and is outdated / no longer supported; removing this test entirely
  • Loading branch information
beeankha authored May 12, 2022
1 parent 0ce67ff commit d8ddda5
Showing 1 changed file with 0 additions and 127 deletions.
127 changes: 0 additions & 127 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,133 +2140,6 @@ def test_multiline_run_command(self):
assert env_which_etc
assert not errs_etc

@pytest.mark.xfail(on_mac, reason="see #11128")
def test_init_dev_and_NoBaseEnvironmentError(self):
# This specific python version is named so that the test suite uses an
# old python build that still hacks 'Library/bin' into PATH. Really, we
# should run all of these conda commands through run_command(RUN) which
# would wrap them with activation.

# We pass --copy because otherwise the call to conda init --dev will overwrite
# the following files in the package cache:
# Library/bin/conda.bat
# Scripts/activate.bat
# Scripts/conda-env-script.py
# Scripts/conda-script.py
# .. and from then onwards, that conda package is corrupt in the cache.
# Note: We were overwriting some *old* conda package with files from this latest
# source code. Urgh.

conda_v = "4.5.13"
python_v = "3.6.7"
# conda-package-handling is necessary here because we install a dev version of conda
with make_temp_env("conda="+conda_v, "python="+python_v, "git",
"conda-package-handling", "--copy",
name='_' + str(uuid4())[:8]) as prefix:
# We cannot naively call $SOME_PREFIX/bin/conda and expect it to run the right conda because we
# respect PATH (i.e. our conda shell script (in 4.5 days at least) has the following shebang:
# `#!/usr/bin/env python`). Now it may be that `PYTHONPATH` or something was meant to account
# for this and my clean_env stuff gets in the way but let's just be explicit about the Python
# instead. If we ran any conda stuff that needs ssl on Windows then we'd need to use
# Commands.RUN here, but on Unix we'll be fine.
conda_exe = join(prefix, 'Scripts', 'conda.exe') if on_win else join(prefix, 'bin', 'conda')
with env_var('CONDA_BAT' if on_win else 'CONDA_EXE', conda_exe, stack_callback=conda_tests_ctxt_mgmt_def_pol):
result = subprocess_call_with_clean_env([conda_exe, "--version"], path=prefix)
assert result.rc == 0
# Python returns --version in stderr. This used to `assert not result.stderr` and I am
# not entirely sure why that didn't cause problems before. Unfortunately pycharm outputs
# 'pydev debugger: process XXXX is connecting" to stderr sometimes. Need to see why we
# are crossing our streams.
# assert not (result.stderr and result.stdout), "--version should output to one stream only"
version = result.stdout if result.stdout else result.stderr
assert version.startswith("conda ")
conda_version = version.strip()[6:]
assert conda_version == conda_v

# When we run `conda run -p prefix python -m conda init` we are explicitly wishing to run the
# old Python 3.6.7 in prefix, but against the development sources of conda. Those are found
# via `workdir=CONDA_SOURCE_ROOT`.
#
# This was beyond complicated to deal with and led to adding a new 'dev' flag which modifies
# what the script wrappers emit for `CONDA_EXE`.
#
# Normal mode: CONDA_EXE=[join(prefix,'bin','conda')]
# Dev mode: CONDA_EXE=[join(root.prefix+'bin'+'python'), '-m', 'conda']
#
# When you next need to debug this stuff (and you will), the following may help you:
#

'''
env_path_etc, errs_etc, _ = run_command(Commands.RUN, prefix, '--cwd', CONDA_SOURCE_ROOT, dedent("""
declare -f
env | sort
which conda
cat $(which conda)
echo $PATH
conda info
"""), dev=True)
log.warning(env_path_etc)
log.warning(errs_etc)
'''

# Let us test that the conda we expect to be running in that scenario
# is the conda that actually runs:
conda__file__, stderr, _ = run_command(
Commands.RUN,
prefix,
"--cwd",
CONDA_SOURCE_ROOT,
sys.executable,
"-c",
"import conda, os, sys; " "sys.stdout.write(os.path.abspath(conda.__file__))",
dev=True,
)
assert dirname(dirname(conda__file__)) == CONDA_SOURCE_ROOT

# (and the same thing for Python)
python_v2, _, _ = run_command(
Commands.RUN,
prefix,
"--cwd",
CONDA_SOURCE_ROOT,
"python",
"-c",
"import os, sys; "
"sys.stdout.write(str(sys.version_info[0]) + '.' + "
" str(sys.version_info[1]) + '.' + "
" str(sys.version_info[2]))", dev=True)
assert python_v2 == python_v

# install a dev version with our current source checkout into prefix
args = ["python", "-m", "conda", "init", *(["cmd.exe"] if on_win else []), "--dev"]
result, stderr, _ = run_command(
Commands.RUN,
prefix,
"--cwd",
CONDA_SOURCE_ROOT,
*args,
dev=True,
)

result = subprocess_call_with_clean_env("%s --version" % conda_exe)
assert result.rc == 0
assert not result.stderr
assert result.stdout.startswith("conda ")
conda_version = result.stdout.strip()[6:]
assert conda_version == CONDA_VERSION

rm_rf(join(prefix, 'conda-meta', 'history'))

result = subprocess_call_with_clean_env("%s info -a" % conda_exe)
print(result.stdout)

if not on_win:
# Windows has: Fatal Python error: failed to get random numbers to initialize Python
result = subprocess_call("%s install python" % conda_exe, env={"SHLVL": "1"},
raise_on_error=False)
assert result.rc == 1
assert "NoBaseEnvironmentError: This conda installation has no default base environment." in result.stderr

@pytest.mark.skip('Test is flaky')
def test_conda_downgrade(self):
# Create an environment with the current conda under test, but include an earlier
Expand Down

0 comments on commit d8ddda5

Please sign in to comment.