diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2c0112 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/pytest-mpl-0.9.tar.gz diff --git a/0001-Increase-tolerance-for-new-FreeType.patch b/0001-Increase-tolerance-for-new-FreeType.patch new file mode 100644 index 0000000..643c40f --- /dev/null +++ b/0001-Increase-tolerance-for-new-FreeType.patch @@ -0,0 +1,54 @@ +From 75beaec80c54b6fff92e310f2e2194ce119deba8 Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Mon, 16 Jul 2018 00:52:13 -0400 +Subject: [PATCH 1/2] Increase tolerance for new FreeType. + +Signed-off-by: Elliott Sales de Andrade +--- + tests/test_pytest_mpl.py | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/tests/test_pytest_mpl.py b/tests/test_pytest_mpl.py +index 0d9518c..1439eaf 100644 +--- a/tests/test_pytest_mpl.py ++++ b/tests/test_pytest_mpl.py +@@ -23,7 +23,7 @@ baseline_dir_remote = 'http://matplotlib.github.io/pytest-mpl/' + baseline_subdi + WIN = sys.platform.startswith('win') + + +-@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir_local) ++@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir_local, tolerance=7.1) + def test_succeeds(): + fig = plt.figure() + ax = fig.add_subplot(1, 1, 1) +@@ -52,7 +52,8 @@ def test_succeeds_faulty_mirror(): + + class TestClass(object): + +- @pytest.mark.mpl_image_compare(baseline_dir=baseline_dir_local) ++ @pytest.mark.mpl_image_compare(baseline_dir=baseline_dir_local, ++ tolerance=7.1) + def test_succeeds(self): + fig = plt.figure() + ax = fig.add_subplot(1, 1, 1) +@@ -175,7 +176,7 @@ def test_nofigure(): + + @pytest.mark.skipif(MPL_LT_2, reason="the fivethirtyeight style is only available in Matplotlib 2.0 and later") + @pytest.mark.mpl_image_compare(baseline_dir=baseline_dir_local, +- style='fivethirtyeight') ++ style='fivethirtyeight', tolerance=7.5) + def test_base_style(): + fig = plt.figure() + ax = fig.add_subplot(1, 1, 1) +@@ -210,7 +211,7 @@ class TestClassWithSetup(object): + self.x = [1, 2, 3] + + @pytest.mark.mpl_image_compare(baseline_dir=baseline_dir_local, +- filename='test_succeeds.png') ++ filename='test_succeeds.png', tolerance=7.1) + def test_succeeds(self): + fig = plt.figure() + ax = fig.add_subplot(1, 1, 1) +-- +2.17.1 + diff --git a/0002-Use-correct-pytest-executable.patch b/0002-Use-correct-pytest-executable.patch new file mode 100644 index 0000000..8cad39f --- /dev/null +++ b/0002-Use-correct-pytest-executable.patch @@ -0,0 +1,56 @@ +From f698c728cb726a22a5fda09a9ef7cb7f402bcc13 Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Mon, 16 Jul 2018 02:00:16 -0400 +Subject: [PATCH 2/2] Use correct pytest executable. + +Signed-off-by: Elliott Sales de Andrade +--- + tests/test_pytest_mpl.py | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/tests/test_pytest_mpl.py b/tests/test_pytest_mpl.py +index 1439eaf..522d6d0 100644 +--- a/tests/test_pytest_mpl.py ++++ b/tests/test_pytest_mpl.py +@@ -87,11 +87,11 @@ def test_fails(tmpdir): + f.write(TEST_FAILING) + + # If we use --mpl, it should detect that the figure is wrong +- code = subprocess.call('py.test --mpl {0}'.format(test_file), shell=True) ++ code = subprocess.call('pytest-3 --mpl {0}'.format(test_file), shell=True) + assert code != 0 + + # If we don't use --mpl option, the test should succeed +- code = subprocess.call('py.test {0}'.format(test_file), shell=True) ++ code = subprocess.call('pytest-3 {0}'.format(test_file), shell=True) + assert code == 0 + + +@@ -114,7 +114,7 @@ def test_output_dir(tmpdir): + + # When we run the test, we should get output images where we specify + output_dir = tmpdir.join('test_output_dir').strpath +- code = subprocess.call('py.test --mpl-results-path={0} --mpl {1}'.format(output_dir, test_file), ++ code = subprocess.call('pytest-3 --mpl-results-path={0} --mpl {1}'.format(output_dir, test_file), + shell=True) + + assert code != 0 +@@ -151,13 +151,13 @@ def test_generate(tmpdir): + gen_dir = tmpdir.mkdir('spam').mkdir('egg').strpath + + # If we don't generate, the test will fail +- p = subprocess.Popen('py.test --mpl {0}'.format(test_file), shell=True, ++ p = subprocess.Popen('pytest-3 --mpl {0}'.format(test_file), shell=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p.wait() + assert b'Image file not found for comparison test' in p.stdout.read() + + # If we do generate, the test should succeed and a new file will appear +- code = subprocess.call('py.test --mpl-generate-path={0} {1}'.format(gen_dir, test_file), shell=True) ++ code = subprocess.call('pytest-3 --mpl-generate-path={0} {1}'.format(gen_dir, test_file), shell=True) + assert code == 0 + assert os.path.exists(os.path.join(gen_dir, 'test_gen.png')) + +-- +2.17.1 + diff --git a/README.md b/README.md deleted file mode 100644 index f7e32d2..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# python-pytest-mpl - -The python-pytest-mpl package \ No newline at end of file diff --git a/python-pytest-mpl.spec b/python-pytest-mpl.spec new file mode 100644 index 0000000..e7b1476 --- /dev/null +++ b/python-pytest-mpl.spec @@ -0,0 +1,79 @@ +%global srcname pytest-mpl + +Name: python-%{srcname} +Version: 0.9 +Release: 2%{?dist} +Summary: Pytest plugin for testing figure output from Matplotlib + +License: BSD +URL: https://github.com/matplotlib/pytest-mpl +Source0: https://files.pythonhosted.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.gz +# Probably not going upstream. +Patch0001: 0001-Increase-tolerance-for-new-FreeType.patch +Patch0002: 0002-Use-correct-pytest-executable.patch + +BuildArch: noarch + +%global _description \ +This is a plugin to facilitate image comparison for Matplotlib figures in \ +pytest. Matplotlib includes a number of test utilities and decorators, but \ +these are geared towards the nose testing framework. Pytest-mpl makes it easy \ +to compare figures produced by tests to reference images when using pytest. + +%description %{_description} + + +%package -n python3-%{srcname} +Summary: %{summary} +%{?python_provide:%python_provide python3-%{srcname}} + +BuildRequires: python3-devel +BuildRequires: python3dist(matplotlib) +BuildRequires: python3dist(nose) +BuildRequires: python3dist(pytest) +BuildRequires: python3dist(setuptools) + +Requires: python3dist(matplotlib) +Requires: python3dist(nose) +Requires: python3dist(pytest) +Requires: python3dist(setuptools) + +%description -n python3-%{srcname} %{_description} + + +%prep +%autosetup -n %{srcname}-%{version} -p1 + +# Remove bundled egg-info +rm -rf %{srcname}.egg-info + + +%build +%py3_build + + +%install +%py3_install + + +%check +# Skip networked tests. +PYTHONPATH=%{buildroot}%{python3_sitelib} MPLBACKEND=Agg PYTHONDONTWRITEBYTECODE=1 \ + pytest-3 --mpl tests -k 'not test_succeeds_remote and not test_succeeds_faulty_mirror' +PYTHONPATH=%{buildroot}%{python3_sitelib} MPLBACKEND=Agg PYTHONDONTWRITEBYTECODE=1 \ + pytest-3 tests -k 'not test_succeeds_remote and not test_succeeds_faulty_mirror' + + +%files -n python3-%{srcname} +%license LICENSE +%doc README.rst +%{python3_sitelib}/pytest_mpl +%{python3_sitelib}/pytest_mpl-%{version}-py?.?.egg-info + + +%changelog +* Wed Jul 18 2018 Elliott Sales de Andrade - 0.9-2 +- Remove unnecessary cache files + +* Mon Jul 16 2018 Elliott Sales de Andrade - 0.9-1 +- Initial package. diff --git a/sources b/sources new file mode 100644 index 0000000..4ad8795 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (pytest-mpl-0.9.tar.gz) = 6faa9672c32c03017fac99781558462d76a705fd60232559202aa05a855cd4af960910d73b6dddf960e27e84f92dfc5cab7da0348a61709d71fff37480665d4f