(test_apps, monkeypatch)
| 405 | |
| 406 | |
| 407 | def test_template_loader_debugging(test_apps, monkeypatch): |
| 408 | from blueprintapp import app |
| 409 | |
| 410 | called = [] |
| 411 | |
| 412 | class _TestHandler(logging.Handler): |
| 413 | def handle(self, record): |
| 414 | called.append(True) |
| 415 | text = str(record.msg) |
| 416 | assert "1: trying loader of application 'blueprintapp'" in text |
| 417 | assert ( |
| 418 | "2: trying loader of blueprint 'admin' (blueprintapp.apps.admin)" |
| 419 | ) in text |
| 420 | assert ( |
| 421 | "trying loader of blueprint 'frontend' (blueprintapp.apps.frontend)" |
| 422 | ) in text |
| 423 | assert "Error: the template could not be found" in text |
| 424 | assert ( |
| 425 | "looked up from an endpoint that belongs to the blueprint 'frontend'" |
| 426 | ) in text |
| 427 | assert "See https://flask.palletsprojects.com/blueprints/#templates" in text |
| 428 | |
| 429 | with app.test_client() as c: |
| 430 | monkeypatch.setitem(app.config, "EXPLAIN_TEMPLATE_LOADING", True) |
| 431 | monkeypatch.setattr( |
| 432 | logging.getLogger("blueprintapp"), "handlers", [_TestHandler()] |
| 433 | ) |
| 434 | |
| 435 | with pytest.raises(TemplateNotFound) as excinfo: |
| 436 | c.get("/missing") |
| 437 | |
| 438 | assert "missing_template.html" in str(excinfo.value) |
| 439 | |
| 440 | assert len(called) == 1 |
| 441 | |
| 442 | |
| 443 | def test_custom_jinja_env(): |
nothing calls this directly
no test coverage detected