diff --git a/rest_framework/fields.py b/rest_framework/fields.py index f76e4e801..7d677a408 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -53,6 +53,18 @@ def is_simple_callable(obj): """ True if the object is a callable that takes no arguments. """ + if not hasattr(inspect, 'signature'): + return py2k_is_simple_callable(obj) + + if not callable(obj): + return False + + sig = inspect.signature(obj) + params = sig.parameters.values() + return all(param.default != param.empty for param in params) + + +def py2k_is_simple_callable(obj): function = inspect.isfunction(obj) method = inspect.ismethod(obj) diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 197e62eb0..dc01d8cd8 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -215,4 +215,4 @@ class TestSchemaGenerator(TestCase): } } ) - self.assertEquals(schema, expected) + self.assertEqual(schema, expected)