Description: Fix test_merge.py
 The file was using private pytest stuff, causing FTBFS with latest pytest.
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/1114316
Forwarded: no
Last-Update: 2025-10-27

Index: python-omegaconf/tests/test_merge.py
===================================================================
--- python-omegaconf.orig/tests/test_merge.py
+++ python-omegaconf/tests/test_merge.py
@@ -13,7 +13,6 @@ from typing import (
     Union,
 )
 
-from _pytest.python_api import RaisesContext
 from pytest import mark, param, raises
 
 from omegaconf import (
@@ -800,7 +799,7 @@ def test_optional_element_type_merge(
     inputs: Any, expected: Any, ref_type: Any, is_optional: bool
 ) -> None:
     configs = [_ensure_container(c) for c in inputs]
-    if isinstance(expected, RaisesContext):
+    if hasattr(expected, '__enter__'):
         with expected:
             OmegaConf.merge(*configs)
     else:
@@ -1010,7 +1009,7 @@ def test_optional_element_type_merge(
 )
 def test_union_merge(inputs: Any, expected: Any, type_hint: Any) -> None:
     configs = [_ensure_container(c) for c in inputs]
-    if isinstance(expected, RaisesContext):
+    if hasattr(expected, '__enter__'):
         with expected:
             OmegaConf.merge(*configs)
     else:
Index: python-omegaconf/tests/test_basic_ops_list.py
===================================================================
--- python-omegaconf.orig/tests/test_basic_ops_list.py
+++ python-omegaconf/tests/test_basic_ops_list.py
@@ -4,7 +4,6 @@ from pathlib import Path
 from textwrap import dedent
 from typing import Any, Callable, List, MutableSequence, Optional, Union
 
-from _pytest.python_api import RaisesContext
 from pytest import mark, param, raises
 
 from omegaconf import MISSING, AnyNode, DictConfig, ListConfig, OmegaConf, flag_override
@@ -16,6 +15,7 @@ from omegaconf.errors import (
     InterpolationToMissingValueError,
     KeyValidationError,
     MissingMandatoryValue,
+    OmegaConfBaseException,
     UnsupportedValueType,
     ValidationError,
 )
@@ -968,7 +968,7 @@ def test_setitem_slice(
     lst: List[Any],
     idx: slice,
     value: Union[List[Any], Any],
-    expected: Union[List[Any], RaisesContext[Any]],
+    expected: Union[List[Any], Any],
     constructor: Callable[[List[Any]], MutableSequence[Any]],
 ) -> None:
     cfg = constructor(lst)
@@ -976,13 +976,20 @@ def test_setitem_slice(
         cfg[idx] = value
         assert cfg == expected
     else:
-        expected_exception: Any = expected.expected_exception
-        if type(constructor) == type(list) and issubclass(
-            expected_exception, UnsupportedValueType
-        ):
-            return  # standard list() can accept object() so skip
+        expected_exception: Any = getattr(expected, 'expected_exception', None)
+
+        # Special case: plain Python list cannot raise OmegaConf-specific exceptions
+        if (constructor is list and
+            expected_exception is not None and
+            isinstance(expected_exception, type)):
+
+            if issubclass(expected_exception, OmegaConfBaseException):
+                # Plain Python list should accept the value - this is correct behavior
+                cfg[idx] = value
+                return
+
         orig_cfg = cfg[:]
-        with expected:
+        with expected:  # type: ignore
             cfg[idx] = value
         assert cfg == orig_cfg
 
Index: python-omegaconf/tests/structured_conf/test_structured_config.py
===================================================================
--- python-omegaconf.orig/tests/structured_conf/test_structured_config.py
+++ python-omegaconf/tests/structured_conf/test_structured_config.py
@@ -8,7 +8,7 @@ from pathlib import Path
 from types import LambdaType
 from typing import Any, Callable, Dict, List, Optional, Tuple, Union
 
-from _pytest.python_api import RaisesContext
+import pytest
 from pytest import fixture, mark, param, raises
 
 from omegaconf import (
@@ -2268,7 +2268,7 @@ class TestUnionsOfPrimitiveTypes:
         class_ = getattr(module.UnionsOfPrimitveTypes, class_name)
         cfg = OmegaConf.structured(class_)
 
-        if isinstance(expected, RaisesContext):
+        if hasattr(expected, '__enter__'):
             with expected:
                 cfg[key] = value
 
@@ -2329,7 +2329,7 @@ class TestUnionsOfPrimitiveTypes:
 
         assert _utils._get_value(cfg._get_node(key)) == value
 
-        if isinstance(expected, RaisesContext):
+        if hasattr(expected, '__enter__'):
             with expected:
                 cfg[key]
         else:
@@ -2362,7 +2362,7 @@ class TestUnionsOfPrimitiveTypes:
         class_ = module.UnionsOfPrimitveTypes.InterpolationToUnion
         cfg = OmegaConf.structured(class_)
 
-        if isinstance(expected, RaisesContext):
+        if hasattr(expected, '__enter__'):
             with expected:
                 cfg[key]
         else:
Index: python-omegaconf/tests/test_select.py
===================================================================
--- python-omegaconf.orig/tests/test_select.py
+++ python-omegaconf/tests/test_select.py
@@ -1,6 +1,6 @@
 from typing import Any, Optional
 
-from _pytest.python_api import RaisesContext
+import pytest
 from pytest import mark, param, raises
 
 from omegaconf import DictConfig, ListConfig, MissingMandatoryValue, OmegaConf
@@ -60,7 +60,7 @@ class TestSelect:
     ) -> None:
         cfg = _ensure_container(cfg)
         OmegaConf.set_struct(cfg, struct)
-        if isinstance(expected, RaisesContext):
+        if hasattr(expected, '__enter__'):
             with expected:
                 OmegaConf.select(cfg, key)
         else:
@@ -88,7 +88,7 @@ class TestSelect:
         register_func("func", lambda x: f"_{x}_")
         cfg = _ensure_container(cfg)
         OmegaConf.set_struct(cfg, struct)
-        if isinstance(expected, RaisesContext):
+        if hasattr(expected, '__enter__'):
             with expected:
                 OmegaConf.select(cfg, key)
         else:
@@ -284,7 +284,7 @@ class TestSelect:
 )
 def test_select_resolves_interpolation(cfg: Any, key: str, expected: Any) -> None:
     cfg = _ensure_container(cfg)
-    if isinstance(expected, RaisesContext):
+    if hasattr(expected, '__enter__'):
         with expected:
             OmegaConf.select(cfg, key)
     else:
