Configure pytest options.
(config: pytest.Config)
| 86 | |
| 87 | |
| 88 | def pytest_configure(config: pytest.Config): |
| 89 | """Configure pytest options.""" |
| 90 | # Markers |
| 91 | # can be queried with `pytest --markers` for example |
| 92 | for marker in ( |
| 93 | "slowtest: mark a test as slow", |
| 94 | "ultraslowtest: mark a test as ultraslow or to be run rarely", |
| 95 | "pgtest: mark a test as relevant for mne-qt-browser", |
| 96 | "pvtest: mark a test as relevant for pyvistaqt", |
| 97 | "allow_unclosed: allow unclosed pyvistaqt instances", |
| 98 | ): |
| 99 | config.addinivalue_line("markers", marker) |
| 100 | |
| 101 | # Fixtures |
| 102 | for fixture in ( |
| 103 | "matplotlib_config", |
| 104 | "qt_config", |
| 105 | "protect_config", |
| 106 | ): |
| 107 | config.addinivalue_line("usefixtures", fixture) |
| 108 | |
| 109 | # pytest-qt uses PYTEST_QT_API, but let's make it respect qtpy's QT_API |
| 110 | # if present |
| 111 | if os.getenv("PYTEST_QT_API") is None and os.getenv("QT_API") is not None: |
| 112 | os.environ["PYTEST_QT_API"] = os.environ["QT_API"] |
| 113 | |
| 114 | # suppress: |
| 115 | # Debugger warning: It seems that frozen modules are being used, which may |
| 116 | # make the debugger miss breakpoints. Please pass -Xfrozen_modules=off |
| 117 | # to python to disable frozen modules. |
| 118 | if os.getenv("PYDEVD_DISABLE_FILE_VALIDATION") is None: |
| 119 | os.environ["PYDEVD_DISABLE_FILE_VALIDATION"] = "1" |
| 120 | |
| 121 | # https://numba.readthedocs.io/en/latest/reference/deprecation.html#deprecation-of-old-style-numba-captured-errors # noqa: E501 |
| 122 | if "NUMBA_CAPTURED_ERRORS" not in os.environ: |
| 123 | os.environ["NUMBA_CAPTURED_ERRORS"] = "new_style" |
| 124 | |
| 125 | # Warnings |
| 126 | # - Once SciPy updates not to have non-integer and non-tuple errors (1.2.0) |
| 127 | # we should remove them from here. |
| 128 | # - This list should also be considered alongside reset_warnings in |
| 129 | # doc/conf.py. |
| 130 | if os.getenv("MNE_IGNORE_WARNINGS_IN_TESTS", "") not in ("true", "1"): |
| 131 | first_kind = "error" |
| 132 | else: |
| 133 | first_kind = "always" |
| 134 | warning_lines = f" {first_kind}::" |
| 135 | warning_lines += r""" |
| 136 | # matplotlib->traitlets (notebook) |
| 137 | ignore:Passing unrecognized arguments to super.*:DeprecationWarning |
| 138 | # notebook tests |
| 139 | ignore:There is no current event loop:DeprecationWarning |
| 140 | ignore:unclosed <socket\.socket:ResourceWarning |
| 141 | ignore:unclosed event loop <:ResourceWarning |
| 142 | # ignore if joblib is missing |
| 143 | ignore:joblib not installed.*:RuntimeWarning |
| 144 | # qdarkstyle |
| 145 | ignore:.*Setting theme=.*:RuntimeWarning |