Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added assert on context variable as suggested by @andrewschoen

  • Loading branch information...
commit f91976828bcec2604e7fada95313e2859c196807 1 parent 1ccc9e3
Iacopo Spalletti authored
Showing with 1 addition and 0 deletions.
  1. +1 −0  cms/tests/admin.py
1  cms/tests/admin.py
View
@@ -416,6 +416,7 @@ def test_changelist_unquote(self):
response = pageadmin.changelist_view(request)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed("admin/cms/page/change_list.html")
+ self.assertEquals(response.context["open_menu_trees"], [1,2])

this triggers a failure for me:

ERROR: test_changelist_unquote (cms.tests.admin.AdminTestCase)
This test checks for proper jstree cookie unquoting.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/benjamin/projects/django-cms/cms/tests/admin.py", line 419, in test_changelist_unquote
    self.assertEquals(response.context["open_menu_trees"], [1,2])
AttributeError: 'HttpResponse' object has no attribute 'context'

response is a plain old HttpResponse instance in this case, since you are not using the django test client. Any other ideas how to test this?

Iacopo Spalletti Owner
yakky added a note

Actually, both assertTemplateUsed and accessing response.context will not work in this case, because response is a normal HttpResponse, not a response from the test client.

The above failure is with Django 1.4. With 1,3, I get a different failure (not sure why 1.4 doesn't fail on this line already as well):

======================================================================
ERROR: test_changelist_unquote (cms.tests.admin.AdminTestCase)
This test checks for proper jstree cookie unquoting.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/benjamin/projects/django-cms/cms/tests/admin.py", line 418, in test_changelist_unquote
    self.assertTemplateUsed("admin/cms/page/change_list.html")
TypeError: assertTemplateUsed() takes at least 3 arguments (2 given)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
class AdminFieldsetTests(TestCase):
Benjamin Wohlwend

this triggers a failure for me:

ERROR: test_changelist_unquote (cms.tests.admin.AdminTestCase)
This test checks for proper jstree cookie unquoting.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/benjamin/projects/django-cms/cms/tests/admin.py", line 419, in test_changelist_unquote
    self.assertEquals(response.context["open_menu_trees"], [1,2])
AttributeError: 'HttpResponse' object has no attribute 'context'

response is a plain old HttpResponse instance in this case, since you are not using the django test client. Any other ideas how to test this?

Iacopo Spalletti
Benjamin Wohlwend

Actually, both assertTemplateUsed and accessing response.context will not work in this case, because response is a normal HttpResponse, not a response from the test client.

The above failure is with Django 1.4. With 1,3, I get a different failure (not sure why 1.4 doesn't fail on this line already as well):

======================================================================
ERROR: test_changelist_unquote (cms.tests.admin.AdminTestCase)
This test checks for proper jstree cookie unquoting.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/benjamin/projects/django-cms/cms/tests/admin.py", line 418, in test_changelist_unquote
    self.assertTemplateUsed("admin/cms/page/change_list.html")
TypeError: assertTemplateUsed() takes at least 3 arguments (2 given)
Please sign in to comment.
Something went wrong with that request. Please try again.