File: test_wsgiref.py

package info (click to toggle)
python-wsgi-intercept 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: python: 1,390; makefile: 56; sh: 5
file content (23 lines) | stat: -rw-r--r-- 598 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests
import wsgiref.simple_server

from wsgi_intercept.interceptor import RequestsInterceptor


def load_app():
    return wsgiref.simple_server.demo_app


def test_wsgiref():
    """General test that the wsgiref server behaves.

    This mostly confirms that environ handling is correct in both
    python2 and 3.
    """

    try:
        with RequestsInterceptor(load_app, host='www.example.net', port=80):
            r = requests.get('http://www.example.net')
            print(r.text)
    except Exception as exc:
        assert False, 'wsgi ref server raised exception: %s' % exc