question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'function' object has no attribute 'wrapped' in Django 2.2

See original GitHub issue

In Django 2.2 (works fine in 2.1) tests, connections are overridden/monkey patched with properties that throw errors, specifically the connection.cursor method.

https://github.com/django/django/blob/master/django/test/testcases.py#L210

Graphene also monkey patches connection.cursor.

https://github.com/graphql-python/graphene-django/blob/master/graphene_django/debug/sql/tracking.py#L43

This causes tests to fail when Django attempts to undo the monkey patch. https://github.com/django/django/blob/master/django/test/testcases.py#L220

The following error occurs:

ERROR: tearDownClass (point_of_sale.tests.graphene.queries.e2e_test_cash_and_check_batch_query.CashAndCheckBatchQueryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/cedar/api/common/testing/test_cases/db_test_case.py", line 44, in tearDownClass
    super(TestCase, cls).tearDownClass()
  File "/usr/local/lib/python3.6/dist-packages/django/test/testcases.py", line 244, in tearDownClass
    cls._remove_databases_failures()
  File "/usr/local/lib/python3.6/dist-packages/django/test/testcases.py", line 240, in _remove_databases_failures
    setattr(connection, name, method.wrapped)
AttributeError: 'function' object has no attribute 'wrapped'

----------------------------------------------------------------------

This test is using the Django test client to test the /graphql endpoint. https://docs.djangoproject.com/en/3.0/topics/testing/tools/#overview-and-a-quick-example

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
frankmeszaroscommented, Feb 8, 2021

Hey @crazyscientist , I have been running into this exact issue for the past week and it was driving me crazy! I’m not sure if this will help you but this was what fixed it for me on a relatively standard graphene-django setup:

The error

in your settings.py (or wherever the settings for your tests live), we initially had:

# ... other stuff

GRAPHENE = {}

# ... other stuff

When this is the case, I was seeing the following 😢 : image

The Fix

in your settings.py (or wherever the settings for your tests live), we revised this to:

# ... other stuff

GRAPHENE = {
  "MIDDLEWARE": [] 
}

When this minor change was added, I was no longer getting the error 😄 :
image

🎉 I hope this gets you a little farther along in your adventures, happy coding!

2reactions
sebslomskicommented, Nov 21, 2020

This is caused by the graphene-django debug middleware. In order fix it, set the graphene middlewares to []

Read more comments on GitHub >

github_iconTop Results From Across the Web

'function' object has no attribute 'wrapped' in Django 2.2
AttributeError : 'function' object has no attribute 'wrapped' in Django 2.2.
Read more >
30541 (Django MultiDB tests not loading fixtures as expected.)
I've recently upgraded from Django 2.0 to Django 2.2 and have found the fixture loading ... AttributeError: 'function' object has no attribute 'wrapped'....
Read more >
Django: decorator causes 'function' object has no attribute 'get ...
However, when I wrap the function with the decorator in my urls.py file I get the error: 'function' object has no attribute 'get'...
Read more >
AttributeError at /n 'function' object has no attribute 'objects'
AttributeError at /newstudent ' function ' object has no attribute 'objects' in Django Solved.
Read more >
26.5. unittest.mock — mock object library
Accessing any attribute not in this list will raise an AttributeError . ... The function is called with the same arguments as the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found