Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/7565.dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump pyedb from 0.71.0 to 0.72.0
56 changes: 0 additions & 56 deletions tests/unit/test_clr_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
import sys
from unittest.mock import MagicMock
from unittest.mock import patch
import warnings

import pytest

from ansys.aedt.core import DOTNET_LINUX_WARNING

DOTNET_ROOT = "dummy/root/path"
DOTNET_ROOT_PATH = Path(DOTNET_ROOT)
DOTNETCORE2_FILE = "dummy/dotnetcore2/file"
Expand Down Expand Up @@ -71,56 +68,3 @@ def test_use_system_dotnet(mock_get_coreclr, mock_load, clean_environment) -> No
assert cm.is_clr
assert DOTNET_ROOT_PATH.as_posix() == os.environ["DOTNET_ROOT"]
del os.environ["DOTNET_ROOT"]


@pytest.mark.skipif(os.name != "posix", reason="test for linux behavior")
@patch("dotnetcore2.__file__", new=DOTNETCORE2_FILE)
@patch("pythonnet.load")
@patch("clr_loader.get_coreclr", side_effect=Exception("Dummy exception"))
@patch.object(warnings, "warn")
def test_use_dotnetcore2(mock_warn, mock_get_coreclr, mock_load, clean_environment) -> None:
import ansys.aedt.core.internal.clr_module as cm

assert cm.is_clr
assert DOTNETCORE2_BIN == os.environ["DOTNET_ROOT"]
mock_warn.assert_any_call(DOTNET_LINUX_WARNING)


@pytest.mark.skipif(os.name != "posix", reason="test for linux behavior")
@patch("dotnetcore2.__file__", new=DOTNETCORE2_FILE)
@patch("pythonnet.load")
@patch("clr_loader.find_runtimes", return_value=[])
def test_use_dotnet_root_env_variable_failure(mock_find_runtimes, mock_load, clean_environment) -> None:
os.environ["DOTNET_ROOT"] = DOTNET_ROOT

with pytest.raises(RuntimeError):
import ansys.aedt.core.internal.clr_module # noqa: F401


@pytest.mark.skipif(os.name != "posix", reason="test for linux behavior")
@patch("dotnetcore2.__file__", new=DOTNETCORE2_FILE)
@patch("pythonnet.load")
@patch.object(warnings, "warn")
def test_use_dotnet_root_env_variable_success_dotnetcore2(mock_warn, mock_load, clean_environment, capsys) -> None:
os.environ["DOTNET_ROOT"] = DOTNETCORE2_BIN

import ansys.aedt.core.internal.clr_module as cm

assert cm.is_clr
assert DOTNETCORE2_BIN == os.environ["DOTNET_ROOT"]
assert all(DOTNET_LINUX_WARNING not in call.args for call in mock_warn.call_args_list)


@pytest.mark.skipif(os.name != "posix", reason="test for linux behavior")
@patch("dotnetcore2.__file__", new=DOTNETCORE2_FILE)
@patch("pythonnet.load")
@patch("clr_loader.find_runtimes")
def test_use_dotnet_root_env_variable_success(mock_find_runtimes, mock_load, clean_environment) -> None:
os.environ["DOTNET_ROOT"] = DOTNET_ROOT
mock_runtime = MagicMock()
mock_runtime.name = "Microsoft.NETCore.App"
mock_find_runtimes.return_value = [mock_runtime]

import ansys.aedt.core.internal.clr_module # noqa: F401

assert os.environ["DOTNET_ROOT"]
11 changes: 9 additions & 2 deletions tests/unit/test_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@

@pytest.fixture(scope="module", autouse=True)
def mock_desktop():
"""Fixture used to mock the creation of a Desktop instance."""
with patch("ansys.aedt.core.desktop.Desktop.__init__", lambda x: None):
"""Fixture used to mock the creation of a Desktop instance.

Patching __del__ is necessary to avoid side effects associated to the logic of
releasing and closing the desktop.
"""
with (
patch("ansys.aedt.core.desktop.Desktop.__init__", lambda x: None),
patch("ansys.aedt.core.desktop.Desktop.__del__", lambda x: None),
):
yield


Expand Down
7 changes: 3 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading