(
empty_env: Path,
monkeypatch: MonkeyPatch,
capsys: CaptureFixture,
force_uppercase_boolean: bool,
)
| 1731 | |
| 1732 | @pytest.mark.parametrize("force_uppercase_boolean", [True, False]) |
| 1733 | def test_powershell_basic( |
| 1734 | empty_env: Path, |
| 1735 | monkeypatch: MonkeyPatch, |
| 1736 | capsys: CaptureFixture, |
| 1737 | force_uppercase_boolean: bool, |
| 1738 | ) -> None: |
| 1739 | monkeypatch.setenv("CONDA_ENVVARS_FORCE_UPPERCASE", force_uppercase_boolean) |
| 1740 | reset_context() |
| 1741 | assert context.envvars_force_uppercase == force_uppercase_boolean |
| 1742 | |
| 1743 | activator = PowerShellActivator() |
| 1744 | make_dot_d_files(empty_env, activator.script_extension) |
| 1745 | |
| 1746 | err = main_sourced("shell.powershell", "activate", str(empty_env)) |
| 1747 | activate_data, stderr = capsys.readouterr() |
| 1748 | assert not stderr |
| 1749 | assert not err |
| 1750 | |
| 1751 | new_path_parts = activator._add_prefix_to_path(empty_env) |
| 1752 | conda_exe_export, unset_vars = get_scripts_export_unset_vars(activator) |
| 1753 | activate1 = join(empty_env, "etc", "conda", "activate.d", "activate1.ps1") |
| 1754 | assert activate_data == ( |
| 1755 | f"{unset_vars}\n" |
| 1756 | f'$Env:PATH = "{activator.pathsep_join(new_path_parts)}"\n' |
| 1757 | f'$Env:CONDA_PREFIX = "{empty_env}"\n' |
| 1758 | f'$Env:CONDA_SHLVL = "1"\n' |
| 1759 | f'$Env:CONDA_DEFAULT_ENV = "{empty_env}"\n' |
| 1760 | f'$Env:CONDA_PROMPT_MODIFIER = "{get_prompt_modifier(empty_env)}"\n' |
| 1761 | f"{conda_exe_export}\n" |
| 1762 | f'. "{activate1}"\n' |
| 1763 | ) |
| 1764 | |
| 1765 | monkeypatch.setenv("CONDA_PREFIX", empty_env) |
| 1766 | monkeypatch.setenv("CONDA_SHLVL", "1") |
| 1767 | monkeypatch.setenv("PATH", os.pathsep.join((*new_path_parts, os.environ["PATH"]))) |
| 1768 | |
| 1769 | activator = PowerShellActivator() |
| 1770 | err = main_sourced("shell.powershell", "reactivate") |
| 1771 | reactivate_data, stderr = capsys.readouterr() |
| 1772 | assert not stderr |
| 1773 | assert not err |
| 1774 | |
| 1775 | new_path_parts = activator._replace_prefix_in_path(empty_env, empty_env) |
| 1776 | conda_exe_export, unset_vars = get_scripts_export_unset_vars(activator) |
| 1777 | activate1 = join(empty_env, "etc", "conda", "activate.d", "activate1.ps1") |
| 1778 | deactivate1 = join( |
| 1779 | empty_env, |
| 1780 | "etc", |
| 1781 | "conda", |
| 1782 | "deactivate.d", |
| 1783 | "deactivate1.ps1", |
| 1784 | ) |
| 1785 | assert reactivate_data == ( |
| 1786 | f'. "{deactivate1}"\n' |
| 1787 | f"{unset_vars}\n" |
| 1788 | f'$Env:PATH = "{activator.pathsep_join(new_path_parts)}"\n' |
| 1789 | f'$Env:CONDA_SHLVL = "1"\n' |
| 1790 | f'$Env:CONDA_PROMPT_MODIFIER = "{get_prompt_modifier(empty_env)}"\n' |
nothing calls this directly
no test coverage detected
searching dependent graphs…