Repository: matplotlib/matplotlib
Pull request: TST: forgive more failures on pyside2 / pyside6 cross imports
## PR Summary

closes #23004

This is testing that we warn something is a bad idea and failing because it is indeed a bad idea.

## PR Checklist

<!-- Please mark any checkboxes that do not apply to this PR as [N/A]. -->
**Tests and Styling**
- [x] Has pytest style unit tests (and `pytest` passes).
- [x] Is [Flake 8](https://flake8.pycqa.org/en/latest/) compliant (install `flake8-docstrings` and run `flake8 --docstring-convention=all`).


Problem statement:
[Bug]: test failure of test_cross_Qt_imports in 3.5.2
### Bug summary

While building 3.5.2 for Arch Linux, I’ve encountered a test failure for test_cross_Qt_imports.

### Code for reproduction

```python
xvfb-run -a -s "-screen 0 640x480x24" test-env/bin/python -m pytest -ra -n auto -v --color=yes --pyargs matplotlib mpl_toolkits.tests
```


### Actual outcome

```python
____________________________ test_cross_Qt_imports _____________________________
[gw1] linux -- Python 3.10.4 /build/python-matplotlib/src/matplotlib/test-env/bin/python

    def test_cross_Qt_imports():
        qt5_bindings = [
            dep for dep in ['PyQt5', 'PySide2']
            if importlib.util.find_spec(dep) is not None
        ]
        qt6_bindings = [
            dep for dep in ['PyQt6', 'PySide6']
            if importlib.util.find_spec(dep) is not None
        ]
        if len(qt5_bindings) == 0 or len(qt6_bindings) == 0:
            pytest.skip('need both QT6 and QT5 bindings')
    
        for qt5 in qt5_bindings:
            for qt6 in qt6_bindings:
                for pair in ([qt5, qt6], [qt6, qt5]):
                    try:
>                       _run_helper(_impl_test_cross_Qt_imports,
                                    *pair,
                                    timeout=_test_timeout)

test-env/lib/python3.10/site-packages/matplotlib-3.5.2-py3.10-linux-x86_64.egg/matplotlib/tests/test_backends_interactive.py:347: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test-env/lib/python3.10/site-packages/matplotlib-3.5.2-py3.10-linux-x86_64.egg/matplotlib/testing/__init__.py:73: in subprocess_run_helper
    proc = subprocess.run(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

input = None, capture_output = False, timeout = 60, check = True
popenargs = (['/build/python-matplotlib/src/matplotlib/test-env/bin/python', '-c', '\nfrom matplotlib.tests.test_backends_interactive import _impl_test_cross_Qt_imports\n_impl_test_cross_Qt_imports()\n', 'PySide2', 'PySide6'],)
kwargs = {'env': {'BUILDTOOL': 'devtools', 'BUILDTOOLVER': '20220207-2-any', 'CFLAGS': '-march=x86-64 -mtune=generic -O2 -pipe ...f-protection -flto=auto', 'CHOST': 'x86_64-pc-linux-gnu', ...}, 'stderr': -1, 'stdout': -1, 'universal_newlines': True}
process = <Popen: returncode: -6 args: ['/build/python-matplotlib/src/matplotlib/test-...>
stdout = ''
stderr = "python: /build/pyside2/src/pyside-setup-opensource-src-5.15.3/sources/shiboken2/libshiboken/signature/signature_helper.cpp:116: int add_more_getsets(PyTypeObject*, PyGetSetDef*, PyObject**): Assertion `false' failed.\n"
retcode = -6

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if kwargs.get('stdin') is not None:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired as exc:
                process.kill()
                if _mswindows:
                    # Windows accumulates the output in a single blocking
                    # read() call run on child threads, with the timeout
                    # being done in a join() on those threads.  communicate()
                    # _after_ kill() is required to collect that and add it
                    # to the exception.
                    exc.stdout, exc.stderr = process.communicate()
                else:
                    # POSIX _communicate already populated the output so
                    # far into the TimeoutExpired exception.
                    process.wait()
                raise
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
>               raise CalledProcessError(retcode, process.args,
                                         output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '['/build/python-matplotlib/src/matplotlib/test-env/bin/python', '-c', '\nfrom matplotlib.tests.test_backends_interactive import _impl_test_cross_Qt_imports\n_impl_test_cross_Qt_imports()\n', 'PySide2', 'PySide6']' died with <Signals.SIGABRT: 6>.

/usr/lib/python3.10/subprocess.py:524: CalledProcessError
```

### Expected outcome

No failure.

### Additional information

_No response_

### Operating system

Arch

### Matplotlib Version

3.5.2

### Matplotlib Backend

N/A

### Python version

3.10

### Jupyter version

_No response_

### Installation

git checkout

Hints from issue discussion:
SIGABRT means your Qt5/6 crashed; not sure we can do anything about that.
The point of that test is so we can warn if the user is doing something that is a really bad idea (trying to use Qt5 and Qt6 in the same process) before it crashes.

We already have a cut-out for segfault (-11), I think the fix is to also allow exit code 6 .

Commit message: TST: forgive more failures on pyside2 / pyside6 cross imports

closes #23004

Patch to review:
diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py
index bd56c3c58a38..95f6b824c1d4 100644
--- a/lib/matplotlib/tests/test_backends_interactive.py
+++ b/lib/matplotlib/tests/test_backends_interactive.py
@@ -359,6 +359,10 @@ def test_cross_Qt_imports():
                     # are doing something that we do not expect to work
                     if ex.returncode == -11:
                         continue
+                    # We got the abort signal which is likely because the Qt5 /
+                    # Qt6 cross import is unhappy, carry on.
+                    elif ex.returncode == -6:
+                        continue
                     raise
 
 


Code review comments:
diff_hunk: @@ -359,6 +359,10 @@ def test_cross_Qt_imports():
                     # are doing something that we do not expect to work
                     if ex.returncode == -11:
                         continue
+                    # We got the abort signal which is likely because the Qt5 /
+                    # Qt6 cross import is unhappy, carry on.
+                    elif ex.returncode == -6:
path: lib/matplotlib/tests/test_backends_interactive.py
text: @user1:
perhaps `== -signal.SIGABRT` here (and likewise `-signal.SIGSEGV` just above)?

@author:
done.