File: test_request.py

package info (click to toggle)
python-django-debug-toolbar 1%3A1.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,628 kB
  • ctags: 506
  • sloc: python: 2,789; makefile: 181; sh: 1
file content (33 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# coding: utf-8

from __future__ import absolute_import, unicode_literals

from django.utils import six

from ..base import BaseTestCase


class RequestPanelTestCase(BaseTestCase):

    def setUp(self):
        super(RequestPanelTestCase, self).setUp()
        self.panel = self.toolbar.get_panel_by_id('RequestPanel')

    def test_non_ascii_session(self):
        self.request.session = {'où': 'où'}
        if not six.PY3:
            self.request.session['là'.encode('utf-8')] = 'là'.encode('utf-8')
        self.panel.process_request(self.request)
        self.panel.process_response(self.request, self.response)
        content = self.panel.content
        if six.PY3:
            self.assertIn('où', content)
        else:
            self.assertIn('o\\xf9', content)
            self.assertIn('l\\xc3\\xa0', content)

    def test_object_with_non_ascii_repr_in_request_params(self):
        self.request.path = '/non_ascii_request/'
        self.panel.process_request(self.request)
        self.panel.process_response(self.request, self.response)
        self.assertIn('nôt åscíì', self.panel.content)