test_templatetags: use inspect.isfunction in py3 (#38781)

In py2 inspect.ismethod returns bound or unbound method
whereas is py3 it return only bound method.
This commit is contained in:
Emmanuel Cazenave 2020-01-22 18:23:31 +01:00
parent ae0d8e30f4
commit a8cd830419
1 changed files with 3 additions and 2 deletions

View File

@ -17,7 +17,7 @@
import inspect
from django.apps import apps
from django.utils import translation
from django.utils import six, translation
from passerelle.base.templatetags.passerelle import render_body_schemas, render_json_schema
@ -25,6 +25,7 @@ from passerelle.base.templatetags.passerelle import render_body_schemas, render_
def test_render_body_schemas(db):
# FIXME: db should be required but the way ProxyLogger is initialized force an access to the DB
def collect_schemas():
predicate = inspect.isfunction if six.PY3 else inspect.ismethod
for app in apps.get_app_configs():
connector_model = None
if not hasattr(app, 'get_connector_model'):
@ -32,7 +33,7 @@ def test_render_body_schemas(db):
connector_model = app.get_connector_model()
if connector_model is None:
continue
for name, method in inspect.getmembers(connector_model, inspect.ismethod):
for name, method in inspect.getmembers(connector_model, predicate):
if not hasattr(method, 'endpoint_info'):
continue
if method.endpoint_info.post and method.endpoint_info.post.get('request_body', {}).get('schema'):