Skip to content

Commit 6413b36

Browse files
Merge pull request #234 from ConorMacBride/remove-hashes
Generate baseline hashes during tests to reduce flakiness
2 parents 29fd890 + c41a59a commit 6413b36

35 files changed

+92
-812
lines changed

.github/workflows/test_and_publish.yml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,27 @@ jobs:
2626
- ghostscript
2727
- inkscape
2828
envs: |
29-
# Test oldest NEP 29 configurations
29+
# Test oldest SPEC 0 configurations
30+
- linux: py311-test-mpl38
31+
- macos: py311-test-mpl38
32+
- windows: py311-test-mpl38
33+
# Test newest configurations
34+
- linux: py313-test-mpl310
35+
- macos: py313-test-mpl310
36+
- windows: py313-test-mpl310
37+
# Test intermediate SPEC 0 configurations on Linux
38+
- linux: py311-test-mpl39
39+
- linux: py312-test-mpl39
40+
- linux: py311-test-mpl310
41+
- linux: py312-test-mpl310
42+
# Test non-SPEC 0 configurations
43+
- linux: py313-test-mpldev-pytestdev
44+
- linux: py311-test-mpl37-pytest74
45+
- linux: py39-test-mpl33-pytest62
46+
# Test oldest non-SPEC 0 configurations
3047
- linux: py39-test-mpl33
3148
- macos: py39-test-mpl33
3249
- windows: py39-test-mpl33
33-
# Test oldest non-NEP 29 configurations
34-
- linux: py36-test-mpl20
35-
runs-on: ubuntu-20.04
36-
- macos: py36-test-mpl20
37-
- windows: py36-test-mpl20
38-
# Test newest configurations
39-
- linux: py312-test-mpl38
40-
- macos: py312-test-mpl38
41-
- windows: py312-test-mpl38
42-
# Test intermediate NEP 29 configurations on Linux
43-
- linux: py39-test-mpl38
44-
- linux: py310-test-mpl38
45-
- linux: py310-test-mpl35
46-
- linux: py311-test-mpl36
47-
- linux: py311-test-mpl37
48-
# Test different versions of pytest
49-
- linux: py312-test-mpldev-pytestdev
50-
- linux: py39-test-mpl33-pytest62
51-
- linux: py38-test-mpl31-pytest54
5250
coverage: 'codecov'
5351

5452
publish:
@@ -57,7 +55,5 @@ jobs:
5755
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1
5856
with:
5957
test_command: pytest $GITHUB_WORKSPACE/tests; pytest --mpl $GITHUB_WORKSPACE/tests
60-
# Remove python-version when python-dateutil >2.8.2
61-
python-version: "3.11"
6258
secrets:
6359
pypi_token: ${{ secrets.pypi_password }}

.readthedocs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ build:
55
tools:
66
python: "3.11"
77

8+
sphinx:
9+
configuration: docs/conf.py
10+
811
python:
912
install:
1013
- method: pip

docs/installing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Installation Guide
55
##################
66

7-
This plugin is compatible with Python 3.6 and later, and
7+
This plugin is compatible with Python 3.9 and later, and
88
requires `pytest <http://pytest.org>`__ and
99
`matplotlib <http://www.matplotlib.org>`__ to be installed.
1010

pytest_mpl/plugin.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,22 +411,24 @@ def __init__(
411411
self._test_stats = None
412412
self.return_value = {}
413413

414+
def get_logger(self):
414415
# configure a separate logger for this pluggin which is independent
415416
# of the options that are configured for pytest or for the code that
416417
# is tested; turn debug prints on only if "-vv" or more passed
417-
level = logging.DEBUG if config.option.verbose > 1 else logging.INFO
418-
if config.option.log_cli_format is not None:
419-
fmt = config.option.log_cli_format
418+
level = logging.DEBUG if self.config.option.verbose > 1 else logging.INFO
419+
if self.config.option.log_cli_format is not None:
420+
fmt = self.config.option.log_cli_format
420421
else:
421422
# use pytest's default fmt
422423
fmt = "%(levelname)-8s %(name)s:%(filename)s:%(lineno)d %(message)s"
423424
formatter = logging.Formatter(fmt)
424425
handler = logging.StreamHandler()
425426
handler.setFormatter(formatter)
426-
self.logger = logging.getLogger('pytest-mpl')
427-
self.logger.propagate = False
428-
self.logger.setLevel(level)
429-
self.logger.addHandler(handler)
427+
logger = logging.getLogger('pytest-mpl')
428+
logger.propagate = False
429+
logger.setLevel(level)
430+
logger.addHandler(handler)
431+
return logger
430432

431433
def _file_extension(self, item):
432434
compare = get_compare(item)
@@ -502,7 +504,7 @@ def _download_file(self, baseline, filename):
502504
u = urlopen(base_url + filename)
503505
content = u.read()
504506
except Exception as e:
505-
self.logger.info(f'Downloading {base_url + filename} failed: {repr(e)}')
507+
self.get_logger().info(f'Downloading {base_url + filename} failed: {repr(e)}')
506508
else:
507509
break
508510
else: # Could not download baseline image from any of the available URLs

setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ long_description_content_type = text/x-rst
2323
zip_safe = True
2424
packages = find:
2525
include_package_data = True
26-
python_requires = >=3.6
26+
python_requires = >=3.9
2727
install_requires =
2828
pytest
2929
matplotlib
@@ -41,9 +41,9 @@ test =
4141
pytest-cov
4242
docs =
4343
sphinx
44-
mpl_sphinx_theme>=3.6.0.dev0
44+
mpl_sphinx_theme>=3.9.0
4545
sphinx_design
46-
matplotlib==3.6
46+
matplotlib==3.9.*
4747

4848
[tool:pytest]
4949
testpaths = tests

tests/baseline/hashes/mpl20_ft261.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/baseline/hashes/mpl21_ft261.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/baseline/hashes/mpl22_ft261.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/baseline/hashes/mpl30_ft261.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/baseline/hashes/mpl31_ft261.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/baseline/hashes/mpl32_ft261.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/baseline/hashes/mpl33_ft261.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/baseline/hashes/mpl34_ft261.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/baseline/hashes/mpl35_ft261.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/baseline/hashes/mpl36_ft261.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/baseline/hashes/mpl37_ft261.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/baseline/hashes/mpl38_ft261.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/baseline/test_hash_lib.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/helpers.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from pathlib import Path
32

43
import matplotlib
@@ -20,15 +19,11 @@ def skip_if_format_unsupported(file_format, using_hashes=False):
2019
pytest.skip('SVG comparison is only supported in Matplotlib 3.3 and above')
2120

2221
if using_hashes:
23-
2422
if file_format == 'pdf' and MPL_VERSION < Version('2.1'):
2523
pytest.skip('PDF hashes are only deterministic in Matplotlib 2.1 and above')
2624
elif file_format == 'eps' and MPL_VERSION < Version('2.1'):
2725
pytest.skip('EPS hashes are only deterministic in Matplotlib 2.1 and above')
2826

29-
if using_hashes and not sys.platform.startswith('linux'):
30-
pytest.skip('Hashes for vector graphics are only provided in the hash library for Linux')
31-
3227
if file_format != 'png' and file_format not in converter:
3328
if file_format == 'svg':
3429
pytest.skip('Comparing SVG files requires inkscape to be installed')

tests/subtests/result_hashes/mpl33_ft261.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)