File: test.py

package info (click to toggle)
python-bottle 0.10.11-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,332 kB
  • sloc: python: 4,605; makefile: 191
file content (23 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import unittest
import os
import bottle
from bottle.ext import werkzeug as bw

class WerkzeugTest(unittest.TestCase):
    def setUp(self):
        self.app = bottle.Bottle(catchall=False)
        self.plugin = self.app.install(bw.WerkzeugPlugin())

    def test_resquest_obj(self):
        request = self.plugin.request
        @self.app.get('/')
        def test():
            self.assertEqual(request.environ, bottle.request.environ)
            self.assertNotEqual(request, bottle.request)
            self.assertEqual(request.accept_languages.best, 'de')
            return repr(self.plugin.request)
        self.app({'PATH_INFO':'/', 'REQUEST_METHOD':'GET',
                  'HTTP_ACCEPT_LANGUAGE': 'de, en;q=0.7'}, lambda x, y: None)

if __name__ == '__main__':
    unittest.main()