def test_use_non_default_conda_manager(): called = dict() class MyCondaManager(CondaManager): def __init__(self, frontend): pass def resolve_dependencies(self, package_specs, channels, platforms): return CondaLockSet({}, platforms=[]) def find_environment_deviations(self, *args): called['find_environment_deviations'] = args def fix_environment_deviations(self, *args): called['fix_environment_deviations'] = args def remove_packages(self, *args): called['remove_packages'] = args push_conda_manager_class(MyCondaManager) try: manager = new_conda_manager() manager.find_environment_deviations(None, None) manager.fix_environment_deviations(None, None) manager.remove_packages(None, None) assert dict(find_environment_deviations=(None, None), fix_environment_deviations=(None, None), remove_packages=(None, None)) == called finally: pop_conda_manager_class()
def _push_fake_env_creator(): class HappyCondaManager(CondaManager): def __init__(self, frontend): pass def resolve_dependencies(self, package_specs, channels, platforms): return CondaLockSet({}) def find_environment_deviations(self, prefix, spec): return CondaEnvironmentDeviations(summary="all good", missing_packages=(), wrong_version_packages=(), missing_pip_packages=(), wrong_version_pip_packages=()) def fix_environment_deviations(self, prefix, spec, deviations=None, create=True): pass def remove_packages(self, prefix, packages): pass push_conda_manager_class(HappyCondaManager)
def _push_fake_env_creator(): class HappyCondaManager(CondaManager): def find_environment_deviations(self, prefix, spec): return CondaEnvironmentDeviations(summary="all good", missing_packages=(), wrong_version_packages=(), missing_pip_packages=(), wrong_version_pip_packages=()) def fix_environment_deviations(self, prefix, spec, deviations=None, create=True): pass def remove_packages(self, prefix, packages): pass push_conda_manager_class(HappyCondaManager)
def test_use_non_default_conda_manager(): called = dict() class MyCondaManager(CondaManager): def find_environment_deviations(self, *args): called['find_environment_deviations'] = args def fix_environment_deviations(self, *args): called['fix_environment_deviations'] = args def remove_packages(self, *args): called['remove_packages'] = args push_conda_manager_class(MyCondaManager) try: manager = new_conda_manager() manager.find_environment_deviations(None, None) manager.fix_environment_deviations(None, None) manager.remove_packages(None, None) assert dict(find_environment_deviations=(None, None), fix_environment_deviations=(None, None), remove_packages=(None, None)) == called finally: pop_conda_manager_class()