AttributeError: 'function' object has no attribute 'wrapped' in Django 2.2
See original GitHub issueIn 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
.
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:
- Created 4 years ago
- Reactions:8
- Comments:10 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:When this is the case, I was seeing the following 😢 :
The Fix
in your
settings.py
(or wherever the settings for your tests live), we revised this to:When this minor change was added, I was no longer getting the error 😄 :
🎉 I hope this gets you a little farther along in your adventures, happy coding!
This is caused by the graphene-django debug middleware. In order fix it, set the graphene middlewares to
[]