15
0
forked from pool/python-fire

Accepting request 682932 from home:mcepl:branches:devel:languages:python

- Add fix-issue-164.patch patch to fix gh#google/python-fire#164
  and we can run whole test suite.

OBS-URL: https://build.opensuse.org/request/show/682932
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-fire?expand=0&rev=7
This commit is contained in:
2019-03-08 23:35:04 +00:00
committed by Git OBS Bridge
parent 58753198d6
commit 6446221631
3 changed files with 66 additions and 2 deletions

57
fix-issue-164.patch Normal file
View File

@@ -0,0 +1,57 @@
From 2cc070bb50577ec45fae640b56e02c69feb6f82c Mon Sep 17 00:00:00 2001
From: Andrew Au <cshung@gmail.com>
Date: Fri, 22 Feb 2019 16:23:03 -0800
Subject: [PATCH] Fix issue 164
---
fire/helputils_test.py | 1 -
fire/inspectutils.py | 10 ++++++----
fire/inspectutils_test.py | 2 --
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/fire/helputils_test.py b/fire/helputils_test.py
index 0557122..c3d5055 100644
--- a/fire/helputils_test.py
+++ b/fire/helputils_test.py
@@ -88,7 +88,6 @@ def testHelpStringBuiltin(self):
helpstring = helputils.HelpString('test'.upper)
self.assertIn('Type: builtin_function_or_method', helpstring)
self.assertIn('String form: <built-in method upper of', helpstring)
- self.assertIn('Usage: [VARS ...] [--KWARGS ...]', helpstring)
def testHelpStringIntType(self):
helpstring = helputils.HelpString(int)
diff --git a/fire/inspectutils.py b/fire/inspectutils.py
index 45f7ce6..244a84f 100644
--- a/fire/inspectutils.py
+++ b/fire/inspectutils.py
@@ -74,10 +74,12 @@ class with an __init__ method.
if six.PY2 and hasattr(fn, '__init__'):
fn = fn.__init__
else:
- # If the function is a bound method, we skip the `self` argument.
- is_method = inspect.ismethod(fn)
- skip_arg = is_method and fn.__self__ is not None
-
+ if inspect.ismethod(fn):
+ # If the function is a bound method, we skip the `self` argument.
+ skip_arg = fn.__self__ is not None
+ elif inspect.isbuiltin(fn):
+ # If the function is a bound builtin, we skip the `self` argument.
+ skip_arg = fn.__self__ is not None
return fn, skip_arg
diff --git a/fire/inspectutils_test.py b/fire/inspectutils_test.py
index 8c6dd9a..ba42865 100644
--- a/fire/inspectutils_test.py
+++ b/fire/inspectutils_test.py
@@ -56,8 +56,6 @@ def testGetFullArgSpecFromBuiltin(self):
spec = inspectutils.GetFullArgSpec('test'.upper)
self.assertEqual(spec.args, [])
self.assertEqual(spec.defaults, ())
- self.assertEqual(spec.varargs, 'vars')
- self.assertEqual(spec.varkw, 'kwargs')
self.assertEqual(spec.kwonlyargs, [])
self.assertEqual(spec.kwonlydefaults, {})
self.assertEqual(spec.annotations, {})

View File

@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Sat Mar 9 00:26:12 CET 2019 - Matej Cepl <mcepl@suse.com>
- Add fix-issue-164.patch patch to fix gh#google/python-fire#164
and we can run whole test suite.
-------------------------------------------------------------------
Thu Feb 7 21:02:37 CET 2019 - Matej Cepl <mcepl@suse.com>

View File

@@ -25,6 +25,7 @@ License: Apache-2.0
Group: Development/Languages/Python
URL: https://github.com/google/python-fire
Source: https://files.pythonhosted.org/packages/source/f/fire/fire-%{version}.tar.gz
Patch0: fix-issue-164.patch
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
@@ -45,6 +46,7 @@ interfaces (CLIs) from a Python object.
%prep
%setup -q -n fire-%{version}
%autopatch -p1
%build
%python_build
@@ -54,8 +56,7 @@ interfaces (CLIs) from a Python object.
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
# gh#google/python-fire#164
%python_expand pytest-%{$python_bin_suffix} -k 'not (testFireKeywordArgs or testFireObjectWithDict or testHelpStringBuiltin or testGetFullArgSpecFromBuiltin)' fire
%python_expand pytest-%{$python_bin_suffix} -v fire
%files %{python_files}
%license LICENSE