Skip to content

Parametrize determinism tests. #14871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/2019-07-23-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
API changes
```````````

The ``matplotlib.testing.determinism`` module, which exposes no public API, has
been deleted.
134 changes: 0 additions & 134 deletions lib/matplotlib/testing/determinism.py

This file was deleted.

32 changes: 0 additions & 32 deletions lib/matplotlib/tests/test_backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib.testing.compare import compare_images
from matplotlib.testing.decorators import image_comparison
from matplotlib.testing.determinism import (_determinism_source_date_epoch,
_determinism_check)


with warnings.catch_warnings():
Expand Down Expand Up @@ -137,36 +135,6 @@ def test_pdfpages_fspath():
pdf.savefig(plt.figure())


def test_source_date_epoch():
"""Test SOURCE_DATE_EPOCH support for PDF output"""
_determinism_source_date_epoch("pdf", b"/CreationDate (D:20000101000000Z)")


def test_determinism_plain():
"""Test for reproducible PDF output: simple figure"""
_determinism_check('', format="pdf")


def test_determinism_images():
"""Test for reproducible PDF output: figure with different images"""
_determinism_check('i', format="pdf")


def test_determinism_hatches():
"""Test for reproducible PDF output: figure with different hatches"""
_determinism_check('h', format="pdf")


def test_determinism_markers():
"""Test for reproducible PDF output: figure with different markers"""
_determinism_check('m', format="pdf")


def test_determinism_all():
"""Test for reproducible PDF output"""
_determinism_check(format="pdf")


@image_comparison(['hatching_legend.pdf'])
def test_hatching_legend():
"""Test for correct hatching on patches in legend"""
Expand Down
24 changes: 0 additions & 24 deletions lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import matplotlib.pyplot as plt
from matplotlib import cbook, patheffects
from matplotlib.testing.decorators import image_comparison
from matplotlib.testing.determinism import (_determinism_source_date_epoch,
_determinism_check)


with warnings.catch_warnings():
Expand Down Expand Up @@ -98,28 +96,6 @@ def test_tilde_in_tempfilename(tmpdir):
plt.savefig(base_tempdir / 'tex_demo.eps', format="ps")


def test_source_date_epoch():
"""Test SOURCE_DATE_EPOCH support for PS output"""
# SOURCE_DATE_EPOCH support is not tested with text.usetex,
# because the produced timestamp comes from ghostscript:
# %%CreationDate: D:20000101000000Z00\'00\', and this could change
# with another ghostscript version.
_determinism_source_date_epoch(
"ps", b"%%CreationDate: Sat Jan 01 00:00:00 2000")


def test_determinism_all():
"""Test for reproducible PS output"""
_determinism_check(format="ps")


@needs_usetex
@needs_ghostscript
def test_determinism_all_tex():
"""Test for reproducible PS/tex output"""
_determinism_check(format="ps", usetex=True)


@image_comparison(["empty.eps"])
def test_transparency():
fig, ax = plt.subplots()
Expand Down
59 changes: 0 additions & 59 deletions lib/matplotlib/tests/test_backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,65 +98,6 @@ def test_bold_font_output_with_none_fonttype():
ax.set_title('bold-title', fontweight='bold')


def _test_determinism_save(filename, usetex):
# This function is mostly copy&paste from "def test_visibility"
mpl.rc('svg', hashsalt='asdf')
mpl.rc('text', usetex=usetex)

fig = Figure() # Require no GUI.
ax = fig.add_subplot(111)

x = np.linspace(0, 4 * np.pi, 50)
y = np.sin(x)
yerr = np.ones_like(y)

a, b, c = ax.errorbar(x, y, yerr=yerr, fmt='ko')
for artist in b:
artist.set_visible(False)
ax.set_title('A string $1+2+\\sigma$')
ax.set_xlabel('A string $1+2+\\sigma$')
ax.set_ylabel('A string $1+2+\\sigma$')

fig.savefig(filename, format="svg")


@pytest.mark.parametrize(
"filename, usetex",
# unique filenames to allow for parallel testing
[("determinism_notex.svg", False),
pytest.param("determinism_tex.svg", True, marks=needs_usetex)])
def test_determinism(filename, usetex):
import sys
from subprocess import check_output, STDOUT, CalledProcessError
plots = []
for i in range(3):
# Using check_output and setting stderr to STDOUT will capture the real
# problem in the output property of the exception
try:
check_output(
[sys.executable, '-R', '-c',
'import matplotlib; '
'matplotlib._called_from_pytest = True; '
'matplotlib.use("svg", force=True); '
'from matplotlib.tests.test_backend_svg '
'import _test_determinism_save;'
'_test_determinism_save(%r, %r)' % (filename, usetex)],
stderr=STDOUT)
except CalledProcessError as e:
# it's easier to use utf8 and ask for forgiveness than try
# to figure out what the current console has as an
# encoding :-/
print(e.output.decode(encoding="utf-8", errors="ignore"))
raise e
else:
with open(filename, 'rb') as fd:
plots.append(fd.read())
finally:
os.unlink(filename)
for p in plots[1:]:
assert p == plots[0]


@needs_usetex
def test_missing_psfont(monkeypatch):
"""An error is raised if a TeX font lacks a Type-1 equivalent"""
Expand Down
Loading