File: test_config_middleware.py

package info (click to toggle)
pastedeploy 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 464 kB
  • sloc: python: 1,236; makefile: 106; sh: 17
file content (28 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (3)
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
import pytest

from paste.deploy.config import ConfigMiddleware


class Bug(Exception):
    pass


def app_with_exception(environ, start_response):
    def cont():
        yield b"something"
        raise Bug

    start_response('200 OK', [('Content-type', 'text/html')])
    return cont()


def test_error():
    # This import is conditional due to Paste not yet working on py3k
    try:
        from paste.fixture import TestApp
    except ImportError:
        raise pytest.skip('unable to import TestApp')

    wrapped = ConfigMiddleware(app_with_exception, {'test': 1})
    test_app = TestApp(wrapped)
    pytest.raises(Bug, test_app.get, '/')