From d56098be5a5d25148f5ab0324d3b5ac9b89e52fb4c5efb4ad037ece37aaf06fa Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 9 Dec 2020 10:04:43 +0000 Subject: [PATCH] Accepting request 854212 from home:bnavigator:branches:openSUSE:Factory:Staging:N - Fix test failures * requires astropy >= 4 which removed astropy-helpers * gh#/astropy/pytest-astropy-header#16 pytest-astropy-header-pr16-no-helper-version.patch * gh#/astropy/pytest-astropy-header#29 pytest-astropy-header-pr29-nohelpers.patch OBS-URL: https://build.opensuse.org/request/show/854212 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-astropy-header?expand=0&rev=9 --- ...stropy-header-pr16-no-helper-version.patch | 168 ++++++++++++++++++ pytest-astropy-header-pr29-nohelpers.patch | 53 ++++++ python-pytest-astropy-header.changes | 10 ++ python-pytest-astropy-header.spec | 9 +- 4 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 pytest-astropy-header-pr16-no-helper-version.patch create mode 100644 pytest-astropy-header-pr29-nohelpers.patch diff --git a/pytest-astropy-header-pr16-no-helper-version.patch b/pytest-astropy-header-pr16-no-helper-version.patch new file mode 100644 index 0000000..38f6d33 --- /dev/null +++ b/pytest-astropy-header-pr16-no-helper-version.patch @@ -0,0 +1,168 @@ +From 0d5d2768ba7727977eaa9c750c067c60fa667631 Mon Sep 17 00:00:00 2001 +From: Thomas Robitaille +Date: Tue, 28 Jan 2020 12:40:36 +0000 +Subject: [PATCH] Don't show astropy-helpers version in packages that don't use + it + +--- + CHANGES.rst | 5 +++++ + pytest_astropy_header/display.py | 29 +++++++++++++++--------- + tests/test_display.py | 38 ++++++++++++++++++++++++-------- + 3 files changed, 52 insertions(+), 20 deletions(-) + +diff --git a/CHANGES.rst b/CHANGES.rst +index d215057..5d8af5f 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -1,3 +1,8 @@ ++0.1.3 (unreleased) ++================== ++ ++- Don't show astropy-helpers version in packages that don't use it. [#16] ++ + 0.1.2 (2019-12-18) + ================== + +diff --git a/pytest_astropy_header/display.py b/pytest_astropy_header/display.py +index 48c8a22..e23d820 100644 +--- a/pytest_astropy_header/display.py ++++ b/pytest_astropy_header/display.py +@@ -8,10 +8,14 @@ + import sys + import datetime + import locale +-import math + from collections import OrderedDict + from distutils.version import LooseVersion + ++if sys.version_info[0] >= 3: ++ import builtins ++else: ++ import __builtin__ as builtins ++ + PYTEST_HEADER_MODULES = OrderedDict([('Numpy', 'numpy'), + ('Scipy', 'scipy'), + ('Matplotlib', 'matplotlib'), +@@ -157,17 +161,20 @@ def pytest_report_header(config): + version = 'unknown (no __version__ attribute)' + s += "{module_display}: {version}\n".format(module_display=module_display, version=version) + +- # Helpers version +- if 'astropy_helpers' in TESTED_VERSIONS: +- astropy_helpers_version = TESTED_VERSIONS['astropy_helpers'] +- else: +- try: +- from astropy.version import astropy_helpers_version +- except ImportError: +- astropy_helpers_version = None ++ # Show the astropy-helpers version, if appropriate. We only show this if ++ # the _ASTROPY_SETUP_ variable is set since this indicates an old-style ++ # setup.py that is usually associated with astropy-helpers ++ if getattr(builtins, '_ASTROPY_SETUP_', False): ++ if 'astropy_helpers' in TESTED_VERSIONS: ++ astropy_helpers_version = TESTED_VERSIONS['astropy_helpers'] ++ else: ++ try: ++ from astropy.version import astropy_helpers_version ++ except ImportError: ++ astropy_helpers_version = None + +- if astropy_helpers_version: +- s += "astropy-helpers: {astropy_helpers_version}\n".format(astropy_helpers_version=astropy_helpers_version) ++ if astropy_helpers_version: ++ s += "astropy-helpers: {astropy_helpers_version}\n".format(astropy_helpers_version=astropy_helpers_version) + + s += "\n" + +diff --git a/tests/test_display.py b/tests/test_display.py +index 0525a35..14fc2f5 100644 +--- a/tests/test_display.py ++++ b/tests/test_display.py +@@ -1,7 +1,14 @@ ++import sys + import pytest + + import numpy + ++if sys.version_info[0] >= 3: ++ import builtins ++else: ++ import __builtin__ as builtins ++ ++ + NUMPY_VERSION = numpy.__version__ + + pytest_plugins = ['pytester'] +@@ -42,7 +49,24 @@ def test_enabled(testdir, capsys, method): + def pytest_configure(config): + config.option.astropy_header = True + """) +- testdir.inline_run() ++ testdir.inline_run() ++ out, err = capsys.readouterr() ++ lines = extract_package_version_lines(out) ++ assert len(lines) == 5 ++ assert lines[0].startswith('Numpy: ') ++ assert lines[1].startswith('Scipy: ') ++ assert lines[2].startswith('Matplotlib: ') ++ assert lines[3].startswith('h5py: ') ++ assert lines[4].startswith('Pandas: ') ++ ++ ++ ++def test_astropy_helpers(testdir, capsys): ++ try: ++ builtins._ASTROPY_SETUP_ = True ++ testdir.inline_run("--astropy-header") ++ finally: ++ del builtins._ASTROPY_SETUP_ + out, err = capsys.readouterr() + lines = extract_package_version_lines(out) + assert len(lines) == 6 +@@ -100,9 +124,8 @@ def pytest_configure(config): + testdir.inline_run() + out, err = capsys.readouterr() + lines = extract_package_version_lines(out) +- assert len(lines) == 2 ++ assert len(lines) == 1 + assert lines[0] == 'numpy: {NUMPY_VERSION}'.format(NUMPY_VERSION=NUMPY_VERSION) +- assert lines[1].startswith('astropy-helpers: ') + + + @pytest.mark.parametrize('method', ['cli', 'ini', 'ini_list', 'conftest']) +@@ -135,10 +158,9 @@ def pytest_configure(config): + out, err = capsys.readouterr() + print(out) + lines = extract_package_version_lines(out) +- assert len(lines) == 3 ++ assert len(lines) == 2 + assert lines[0] == 'numpy: {NUMPY_VERSION}'.format(NUMPY_VERSION=NUMPY_VERSION) + assert lines[1].startswith('pandas') +- assert lines[2].startswith('astropy-helpers: ') + + + @pytest.mark.parametrize('method', ['cli', 'ini', 'ini_list', 'conftest']) +@@ -169,9 +191,8 @@ def pytest_configure(config): + testdir.inline_run() + out, err = capsys.readouterr() + lines = extract_package_version_lines(out) +- assert len(lines) == 2 ++ assert len(lines) == 1 + assert lines[0] == 'apackagethatdoesnotexist: not available' +- assert lines[1].startswith('astropy-helpers: ') + + + def test_modify_in_conftest(testdir, capsys): +@@ -188,11 +209,10 @@ def pytest_configure(config): + out, err = capsys.readouterr() + assert err == '' + lines = extract_package_version_lines(out) +- assert len(lines) == 6 ++ assert len(lines) == 5 + assert lines[0].startswith('Numpy: ') + assert lines[1].startswith('Scipy: ') + assert lines[2].startswith('Matplotlib: ') + assert lines[3].startswith('h5py: ') + assert lines[4].startswith('scikit-image: ') +- assert lines[5].startswith('astropy-helpers: ') + assert 'Running tests with fakepackage version 1.0.2' in out diff --git a/pytest-astropy-header-pr29-nohelpers.patch b/pytest-astropy-header-pr29-nohelpers.patch new file mode 100644 index 0000000..8a0cbf9 --- /dev/null +++ b/pytest-astropy-header-pr29-nohelpers.patch @@ -0,0 +1,53 @@ +From 7f282c28f68fe152e6364a4ebb11d59d126b7d82 Mon Sep 17 00:00:00 2001 +From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> +Date: Thu, 12 Nov 2020 16:55:01 -0500 +Subject: [PATCH] TST: No more helpers + +--- + tests/test_display.py | 14 +++----------- + 1 file changed, 3 insertions(+), 11 deletions(-) + +diff --git a/tests/test_display.py b/tests/test_display.py +index 14fc2f5..32d9828 100644 +--- a/tests/test_display.py ++++ b/tests/test_display.py +@@ -1,14 +1,8 @@ +-import sys +-import pytest ++import builtins + ++import pytest + import numpy + +-if sys.version_info[0] >= 3: +- import builtins +-else: +- import __builtin__ as builtins +- +- + NUMPY_VERSION = numpy.__version__ + + pytest_plugins = ['pytester'] +@@ -60,7 +54,6 @@ def pytest_configure(config): + assert lines[4].startswith('Pandas: ') + + +- + def test_astropy_helpers(testdir, capsys): + try: + builtins._ASTROPY_SETUP_ = True +@@ -69,13 +62,12 @@ def test_astropy_helpers(testdir, capsys): + del builtins._ASTROPY_SETUP_ + out, err = capsys.readouterr() + lines = extract_package_version_lines(out) +- assert len(lines) == 6 ++ assert len(lines) == 5 + assert lines[0].startswith('Numpy: ') + assert lines[1].startswith('Scipy: ') + assert lines[2].startswith('Matplotlib: ') + assert lines[3].startswith('h5py: ') + assert lines[4].startswith('Pandas: ') +- assert lines[5].startswith('astropy-helpers: ') + + + @pytest.mark.parametrize('method', ['ini', 'conftest']) diff --git a/python-pytest-astropy-header.changes b/python-pytest-astropy-header.changes index 48b986d..b2b58d2 100644 --- a/python-pytest-astropy-header.changes +++ b/python-pytest-astropy-header.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Wed Dec 9 09:49:05 UTC 2020 - Benjamin Greiner + +- Fix test failures + * requires astropy >= 4 which removed astropy-helpers + * gh#/astropy/pytest-astropy-header#16 + pytest-astropy-header-pr16-no-helper-version.patch + * gh#/astropy/pytest-astropy-header#29 + pytest-astropy-header-pr29-nohelpers.patch + ------------------------------------------------------------------- Thu Aug 16 12:25:00 UTC 2020 - Benjamin Greiner diff --git a/python-pytest-astropy-header.spec b/python-pytest-astropy-header.spec index 93e6a50..49c93f1 100644 --- a/python-pytest-astropy-header.spec +++ b/python-pytest-astropy-header.spec @@ -22,6 +22,8 @@ %global flavor @BUILD_FLAVOR@%{nil} %if "%{flavor}" == "test" %define psuffix -test +# current astropy in TW requires python >= 3.7 +%define skip_python36 1 %bcond_without test %else %define psuffix %{nil} @@ -35,12 +37,15 @@ License: BSD-3-Clause Group: Productivity/Scientific/Astronomy URL: https://github.com/astropy/pytest-astropy-header Source: https://files.pythonhosted.org/packages/source/p/%{modname}/%{modname}-%{version}.tar.gz +Patch0: https://github.com/astropy/pytest-astropy-header/pull/16.patch#/pytest-astropy-header-pr16-no-helper-version.patch +Patch1: https://github.com/astropy/pytest-astropy-header/pull/29.patch#/pytest-astropy-header-pr29-nohelpers.patch BuildRequires: %{python_module setuptools >= 30.3.0} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-pytest >= 2.8 %if %{with test} -BuildRequires: %{python_module astropy >= 3.0} +# Patch0 and Patch1: helpers got removed in astropy 4 +BuildRequires: %{python_module astropy >= 4.0} BuildRequires: %{python_module numpy} BuildRequires: %{python_module pytest >= 2.8} %endif @@ -53,7 +58,7 @@ running pytest. It can be used with packages that are not affiliated with the Astropy project, but is optimized for use with astropy-related projects. %prep -%setup -q -n %{modname}-%{version} +%autosetup -p1 -n %{modname}-%{version} %build %python_build