• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / z3c.evalexception / 5776428566

pending completion
5776428566

push

github

web-flow
Config with pure python template (#8)

* Drop support for Python 2.7, 3.5, 3.6.
* Add support for Python 3.10, 3.11.
* Fix security advisory.

6 of 6 new or added lines in 2 files covered. (100.0%)

70 of 71 relevant lines covered (98.59%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.67
/src/z3c/evalexception/__init__.py
1
import zope.security.management
1✔
2
from paste.evalexception.middleware import EvalException
1✔
3

4

5
class ZopeEvalException(EvalException):
1✔
6
    """Wrapper around Paste's EvalException middleware that simply
7
    tells zope.publisher to let exceptions propagate to the middleware."""
8

9
    def __call__(self, environ, start_response):
1✔
10
        environ['wsgi.handleErrors'] = False
1✔
11
        return super().__call__(environ, start_response)
1✔
12

13

14
def zope_eval_exception(app, global_conf):
1✔
15
    return ZopeEvalException(app)
1✔
16

17

18
def PostMortemDebug(application):
1✔
19
    """Middleware that catches exceptions coming from a
20
    zope.publisher-based application and invokes pdb's post-mortem
21
    debugging facility."""
22
    def middleware(environ, start_response):
1✔
23
        environ['wsgi.handleErrors'] = False
1✔
24
        try:
1✔
25
            yield from application(environ, start_response)
1✔
26
        except Exception:
1✔
27
            import pdb
1✔
28
            import sys
1✔
29
            print("%s:" % sys.exc_info()[0])
1✔
30
            print(sys.exc_info()[1])
1✔
31
            zope.security.management.restoreInteraction()
1✔
32
            try:
1✔
33
                pdb.post_mortem(sys.exc_info()[2])
1✔
34
                raise
1✔
35
            finally:
36
                zope.security.management.endInteraction()
×
37
    return middleware
1✔
38

39

40
def post_mortem_debug(app, global_conf):
1✔
41
    return PostMortemDebug(app)
1✔
42

43

44
def TestApplication(environ, start_response):
1✔
45
    """A simple WSGI app that raises an exception for testing
46
    purposes.  Nothing to see here."""
47
    raise RuntimeError('The test application is raising this.')
1✔
48
    start_response('200 OK',                          # pragma: nocover
49
                   [('Content-type', 'text/plain')])  # pragma: nocover
50
    yield "Test Application"                          # pragma: nocover
51

52

53
def test_application_factory(global_config):
1✔
54
    return TestApplication
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc