Skip to content

tests fail when PYTHONOPTIMIZE is set #10312

Open
@anntzer

Description

@anntzer

Bug report

Bug summary

There used to be one CI run with python -OO (== PYTHONOPTIMIZE=2), but it was accidentally removed in #10217 (it was set via PYTHON_ARGS).

Now there is at least one test are failing in this setup, namely

$ PYTHONOPTIMIZE=2 pytest lib/matplotlib/tests/test_legend.py -k kwdocstring
<elided>
lib/matplotlib/tests/test_legend.py F                                                    [100%]

___________________________________ test_legend_kwdocstrings ___________________________________

    def test_legend_kwdocstrings():
>       stax = get_docstring_section(mpl.axes.Axes.legend, 'Parameters')

lib/matplotlib/tests/test_legend.py:44: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

func = <function Axes.legend at 0x7fc35f690158>, section = 'Parameters'

    def get_docstring_section(func, section):
        """ extract a section from the docstring of a function """
        ll = inspect.getdoc(func)
>       lines = ll.splitlines()
E       AttributeError: 'NoneType' object has no attribute 'splitlines'

lib/matplotlib/tests/test_legend.py:27: AttributeError

===================================== 57 tests deselected ======================================
=========================== 1 failed, 57 deselected in 0.35 seconds ============================

Code for reproduction

# Paste your code here
#
#

Actual outcome

# If applicable, paste the console output here
#
#

Expected outcome

Matplotlib version

  • Operating system:
  • Matplotlib version:
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version:
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions