#2 python36
Merged 5 years ago by churchyard. Opened 5 years ago by carlwgeorge.
rpms/ carlwgeorge/python-click epel7  into  epel7

@@ -1,24 +0,0 @@ 

- From 4fa671b4afdde8e103a03b39dcdc66e1a10a16fa Mon Sep 17 00:00:00 2001

- From: Adam Dangoor <adamdangoor@gmail.com>

- Date: Mon, 31 Jul 2017 17:58:41 +0100

- Subject: [PATCH 1/3] Remove outdated comment about Click 3.0

- 

- ---

-  click/core.py | 1 -

-  1 file changed, 1 deletion(-)

- 

- diff --git a/click/core.py b/click/core.py

- index 7456451..18fa9a5 100644

- --- a/click/core.py

- +++ b/click/core.py

- @@ -68,7 +68,6 @@ def invoke_param_callback(callback, ctx, param, value):

-      args = getattr(code, 'co_argcount', 3)

-  

-      if args < 3:

- -        # This will become a warning in Click 3.0:

-          from warnings import warn

-          warn(Warning('Invoked legacy parameter callback "%s".  The new '

-                       'signature for such callbacks starting with '

- -- 

- 2.14.2

- 

@@ -1,21 +0,0 @@ 

- From 6e7951c511b8316a73d9a8d9c4cc130becd99e93 Mon Sep 17 00:00:00 2001

- From: Adam Dangoor <adamdangoor@gmail.com>

- Date: Mon, 31 Jul 2017 18:06:20 +0100

- Subject: [PATCH 2/3] Add pytest option to not capture warnings

- 

- ---

-  pytest.ini | 2 ++

-  1 file changed, 2 insertions(+)

-  create mode 100644 pytest.ini

- 

- diff --git a/pytest.ini b/pytest.ini

- new file mode 100644

- index 0000000..1ceab94

- --- /dev/null

- +++ b/pytest.ini

- @@ -0,0 +1,2 @@

- +[pytest]

- +addopts = -p no:warnings

- -- 

- 2.14.2

- 

@@ -1,54 +0,0 @@ 

- From e6fb0fe8bc75e7931fe86e95442eec09b49caee7 Mon Sep 17 00:00:00 2001

- From: Adam Dangoor <adamdangoor@gmail.com>

- Date: Mon, 31 Jul 2017 19:45:24 +0100

- Subject: [PATCH 3/3] Catch and test pytest warning

- 

- ---

-  pytest.ini           |  2 --

-  tests/test_compat.py | 15 +++++++++++++--

-  2 files changed, 13 insertions(+), 4 deletions(-)

-  delete mode 100644 pytest.ini

- 

- diff --git a/pytest.ini b/pytest.ini

- deleted file mode 100644

- index 1ceab94..0000000

- --- a/pytest.ini

- +++ /dev/null

- @@ -1,2 +0,0 @@

- -[pytest]

- -addopts = -p no:warnings

- diff --git a/tests/test_compat.py b/tests/test_compat.py

- index e4ecdc8..d86110a 100644

- --- a/tests/test_compat.py

- +++ b/tests/test_compat.py

- @@ -1,3 +1,5 @@

- +import pytest

- +

-  import click

-  

-  

- @@ -11,10 +13,19 @@ if click.__version__ >= '3.0':

-          def cli(foo):

-              click.echo(foo)

-  

- -        result = runner.invoke(cli, ['--foo', 'wat'])

- +        with pytest.warns(Warning) as records:

- +            result = runner.invoke(cli, ['--foo', 'wat'])

- +

- +        [warning_record] = records

- +        warning_message = str(warning_record.message)

- +        assert 'Invoked legacy parameter callback' in warning_message

-          assert result.exit_code == 0

- +        # Depending on the pytest version, the warning message may be

- +        # in `result.output`.

- +        #

- +        # In pytest version 3.1 pytest started capturing warnings by default.

- +        # See https://docs.pytest.org/en/latest/warnings.html#warnings-capture.

-          assert 'WAT' in result.output

- -        assert 'Invoked legacy parameter callback' in result.output

-  

-  

-  def test_bash_func_name():

- -- 

- 2.14.2

- 

file modified
+39 -26
@@ -1,18 +1,23 @@ 

  %global pypi_name click

  

+ # pytest in base RHEL is too old

+ %bcond_with python2_tests

+ 

+ %bcond_without python3_tests

+ 

+ # pytest in EPEL hasn't been built for python3_other yet

+ %bcond_with python3_other_tests

+ 

  Name:           python-%{pypi_name}

  Version:        6.7

- Release:        6%{?dist}

+ Release:        7%{?dist}

  Summary:        Simple wrapper around optparse for powerful command line utilities

  

  License:        BSD

  URL:            https://github.com/mitsuhiko/click

  Source0:        %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz

- # https://bugzilla.redhat.com/show_bug.cgi?id=1500962

- # https://github.com/pallets/click/pull/838

- Patch0:         0001-Remove-outdated-comment-about-Click-3.0.patch

- Patch1:         0002-Add-pytest-option-to-not-capture-warnings.patch

- Patch2:         0003-Catch-and-test-pytest-warning.patch

+ # https://github.com/pallets/click/commit/20b4b1c0d1564ab4ef44b7d27d5b650735e28be3

+ Patch3:         update-tests-to-work-with-newer-pytest-versions.patch

  

  BuildArch:      noarch

  
@@ -28,28 +33,27 @@ 

  Summary:        %{summary}

  %{?python_provide:%python_provide python2-%{pypi_name}}

  BuildRequires:  python2-devel

- %if ! (0%{?rhel} && 0%{?rhel} <= 7)

  BuildRequires:  python2-setuptools

- # pytest in base RHEL is too old, we'll skip the tests there

- BuildRequires:  python2-pytest >= 2.8

- %else

- BuildRequires:  python-setuptools

- %endif

+ %{?with_python2_tests:BuildRequires: python2-pytest >= 2.8}

  

  %description -n python2-%{pypi_name} %{_description}

  

- Python 2 version.

- 

  %package -n     python%{python3_pkgversion}-%{pypi_name}

  Summary:        %{summary}

  %{?python_provide:%python_provide python%{python3_pkgversion}-%{pypi_name}}

  BuildRequires:  python%{python3_pkgversion}-devel

  BuildRequires:  python%{python3_pkgversion}-setuptools

- BuildRequires:  python%{python3_pkgversion}-pytest >= 2.8

+ %{?with_python3_tests:BuildRequires: python%{python3_pkgversion}-pytest >= 2.8}

  

  %description -n python%{python3_pkgversion}-%{pypi_name} %{_description}

  

- Python 3 version.

+ %package -n     python%{python3_other_pkgversion}-%{pypi_name}

+ Summary:        %{summary}

+ BuildRequires:  python%{python3_other_pkgversion}-devel

+ BuildRequires:  python%{python3_other_pkgversion}-setuptools

+ %{?with_python3_other_tests:BuildRequires: python%{python3_other_pkgversion}-pytest >= 2.8}

+ 

+ %description -n python%{python3_other_pkgversion}-%{pypi_name} %{_description}

  

  %prep

  %autosetup -n %{pypi_name}-%{version} -p1
@@ -57,33 +61,42 @@ 

  %build

  %py2_build

  %py3_build

+ %py3_other_build

  

  %install

  %py2_install

  %py3_install

+ %py3_other_install

  

  %check

- export PYTHONPATH=$(pwd)

  export LC_ALL=en_US.UTF-8

- %if ! (0%{?rhel} && 0%{?rhel} <= 7)

- # pytest in base RHEL is too old, we'll skip the tests there

- py.test-%{python2_version} tests --tb=long --verbose

- %endif

- py.test-%{python3_version} tests --tb=long --verbose

+ %{?with_python2_tests:PYTHONPATH=%{buildroot}%{python2_sitelib} py.test-%{python2_version} tests --verbose}

+ %{?with_python3_tests:PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} tests --verbose}

+ %{?with_python3_other_tests:PYTHONPATH=%{buildroot}%{python3_other_sitelib} py.test-%{python3_other_version} tests --verbose}

  

  %files -n python2-%{pypi_name}

  %license LICENSE

  %doc README CHANGES

- %{python2_sitelib}/%{pypi_name}-*.egg-info/

- %{python2_sitelib}/%{pypi_name}/

+ %{python2_sitelib}/%{pypi_name}

+ %{python2_sitelib}/%{pypi_name}-%{version}-py%{python2_version}.egg-info

  

  %files -n python%{python3_pkgversion}-%{pypi_name}

  %license LICENSE

  %doc README CHANGES

- %{python3_sitelib}/%{pypi_name}-*.egg-info/

- %{python3_sitelib}/%{pypi_name}/

+ %{python3_sitelib}/%{pypi_name}

+ %{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info

+ 

+ %files -n python%{python3_other_pkgversion}-%{pypi_name}

+ %license LICENSE

+ %doc README CHANGES

+ %{python3_other_sitelib}/%{pypi_name}

+ %{python3_other_sitelib}/%{pypi_name}-%{version}-py%{python3_other_version}.egg-info

  

  %changelog

+ * Mon Oct 08 2018 Carl George <carl@george.computer> - 6.7-7

+ - Add python3_other subpackage

+ - Backport upstream commit for newer pytest compatibility

+ 

  * Thu Oct 12 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 6.7-6

  - Fixup EPEL packaging

  - Adopt to packaging guidelines

@@ -0,0 +1,62 @@ 

+ From 20b4b1c0d1564ab4ef44b7d27d5b650735e28be3 Mon Sep 17 00:00:00 2001

+ From: Armin Ronacher <armin.ronacher@active-4.com>

+ Date: Sat, 23 Dec 2017 09:27:57 +0100

+ Subject: [PATCH] Updated tests to work with newer pytest versions

+ 

+ ---

+  tests/test_basic.py   | 2 +-

+  tests/test_compat.py  | 9 +++++----

+  tests/test_options.py | 2 +-

+  3 files changed, 7 insertions(+), 6 deletions(-)

+ 

+ diff --git a/tests/test_basic.py b/tests/test_basic.py

+ index 045f6085..960cd327 100644

+ --- a/tests/test_basic.py

+ +++ b/tests/test_basic.py

+ @@ -357,7 +357,7 @@ def cli(foo):

+  def test_evaluation_order(runner):

+      called = []

+  

+ -    def memo(ctx, value):

+ +    def memo(ctx, param, value):

+          called.append(value)

+          return value

+  

+ diff --git a/tests/test_compat.py b/tests/test_compat.py

+ index e4ecdc81..9dacc21d 100644

+ --- a/tests/test_compat.py

+ +++ b/tests/test_compat.py

+ @@ -1,4 +1,5 @@

+  import click

+ +import pytest

+  

+  

+  if click.__version__ >= '3.0':

+ @@ -11,10 +12,10 @@ def legacy_callback(ctx, value):

+          def cli(foo):

+              click.echo(foo)

+  

+ -        result = runner.invoke(cli, ['--foo', 'wat'])

+ -        assert result.exit_code == 0

+ -        assert 'WAT' in result.output

+ -        assert 'Invoked legacy parameter callback' in result.output

+ +        with pytest.warns(Warning, match='Invoked legacy parameter callback'):

+ +            result = runner.invoke(cli, ['--foo', 'wat'])

+ +            assert result.exit_code == 0

+ +            assert 'WAT' in result.output

+  

+  

+  def test_bash_func_name():

+ diff --git a/tests/test_options.py b/tests/test_options.py

+ index 9dd8cdff..8bdda1f1 100644

+ --- a/tests/test_options.py

+ +++ b/tests/test_options.py

+ @@ -199,7 +199,7 @@ def cmd(arg):

+  

+  

+  def test_custom_validation(runner):

+ -    def validate_pos_int(ctx, value):

+ +    def validate_pos_int(ctx, param, value):

+          if value < 0:

+              raise click.BadParameter('Value needs to be positive')

+          return value