diff --git a/am2r_yams/wrapper.py b/am2r_yams/wrapper.py index e8f5479..5966fdd 100644 --- a/am2r_yams/wrapper.py +++ b/am2r_yams/wrapper.py @@ -87,10 +87,6 @@ def _load_cs_environment(): clr.AddReference("YAMS-LIB") -def _unload_cs_environment(): - # Unload dotnet runtime - unload() - @contextmanager def load_wrapper() -> Wrapper: try: @@ -98,9 +94,7 @@ def load_wrapper() -> Wrapper: from YAMS_LIB import Patcher as CSharp_Patcher yield Wrapper(CSharp_Patcher) except Exception as e: - raise YamsException(str(e)) from None - finally: - _unload_cs_environment + raise e def _prepare_environment_and_get_data_win_path(folder: str) -> Path: diff --git a/am2r_yams_tests/test_meta.py b/am2r_yams_tests/test_meta.py index b2dcf29..c502abe 100644 --- a/am2r_yams_tests/test_meta.py +++ b/am2r_yams_tests/test_meta.py @@ -10,15 +10,14 @@ @pytest.fixture(scope="session", autouse=True) def _mock_load_unload(): with patch("am2r_yams.wrapper._load_cs_environment") as mocked_load: - with patch("am2r_yams.wrapper._unload_cs_environment") as mocked_unload: - load("coreclr") - import clr + load("coreclr") + import clr - clr.AddReference("YAMS-LIB") - from YAMS_LIB import Patcher as CSharp_Patcher + clr.AddReference("YAMS-LIB") + from YAMS_LIB import Patcher as CSharp_Patcher - yield - unload() + yield + unload() def test_correct_versions(): @@ -38,5 +37,5 @@ def test_throw_correct_exception(): raise System.Exception("Dummy Exception") - assert excinfo.type is YamsException + assert excinfo.type is System.Exception assert "Dummy Exception" == str(excinfo.value)