diff options
author | Pierre de Buyl <pierre.debuyl@meteo.be> | 2021-11-16 11:58:24 +0100 |
---|---|---|
committer | Pierre de Buyl <pdebuyl@pdebuyl.be> | 2021-12-08 15:29:33 +0100 |
commit | 496c02dd237c1bf99d21d37325c9b89b65aada4a (patch) | |
tree | 4eef18dfaab5a0b0ff83684ee264914a7645e387 /doc/conftest.py | |
parent | ac8e7d43d912ce802a1a26d233468492e71d77ad (diff) | |
download | numpy-496c02dd237c1bf99d21d37325c9b89b65aada4a.tar.gz |
Ignore matplotlib objects output lines
Contains code inspired by
https://github.com/wooyek/pytest-doctest-ellipsis-markers
(MIT license)
Diffstat (limited to 'doc/conftest.py')
-rw-r--r-- | doc/conftest.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/conftest.py b/doc/conftest.py index c091c6c5e..80a29487c 100644 --- a/doc/conftest.py +++ b/doc/conftest.py @@ -4,9 +4,23 @@ Pytest configuration and fixtures for the Numpy test suite. import pytest import numpy import matplotlib +import doctest matplotlib.use('agg', force=True) +# Ignore matplotlib output such as `<matplotlib.image.AxesImage at +# 0x7f956908c280>`. doctest monkeypatching inspired by +# https://github.com/wooyek/pytest-doctest-ellipsis-markers (MIT license) +OutputChecker = doctest.OutputChecker + +class SkipMatplotlibOutputChecker(doctest.OutputChecker): + def check_output(self, want, got, optionflags): + if '<matplotlib.' in got: + got = '' + return OutputChecker.check_output(self, want, got, optionflags) + +doctest.OutputChecker = SkipMatplotlibOutputChecker + @pytest.fixture(autouse=True) def add_np(doctest_namespace): numpy.random.seed(1) |