(app)
| 598 | |
| 599 | |
| 600 | def test_extended_flashing(app): |
| 601 | # Be sure app.testing=True below, else tests can fail silently. |
| 602 | # |
| 603 | # Specifically, if app.testing is not set to True, the AssertionErrors |
| 604 | # in the view functions will cause a 500 response to the test client |
| 605 | # instead of propagating exceptions. |
| 606 | |
| 607 | @app.route("/") |
| 608 | def index(): |
| 609 | flask.flash("Hello World") |
| 610 | flask.flash("Hello World", "error") |
| 611 | flask.flash(Markup("<em>Testing</em>"), "warning") |
| 612 | return "" |
| 613 | |
| 614 | @app.route("/test/") |
| 615 | def test(): |
| 616 | messages = flask.get_flashed_messages() |
| 617 | assert list(messages) == [ |
| 618 | "Hello World", |
| 619 | "Hello World", |
| 620 | Markup("<em>Testing</em>"), |
| 621 | ] |
| 622 | return "" |
| 623 | |
| 624 | @app.route("/test_with_categories/") |
| 625 | def test_with_categories(): |
| 626 | messages = flask.get_flashed_messages(with_categories=True) |
| 627 | assert len(messages) == 3 |
| 628 | assert list(messages) == [ |
| 629 | ("message", "Hello World"), |
| 630 | ("error", "Hello World"), |
| 631 | ("warning", Markup("<em>Testing</em>")), |
| 632 | ] |
| 633 | return "" |
| 634 | |
| 635 | @app.route("/test_filter/") |
| 636 | def test_filter(): |
| 637 | messages = flask.get_flashed_messages( |
| 638 | category_filter=["message"], with_categories=True |
| 639 | ) |
| 640 | assert list(messages) == [("message", "Hello World")] |
| 641 | return "" |
| 642 | |
| 643 | @app.route("/test_filters/") |
| 644 | def test_filters(): |
| 645 | messages = flask.get_flashed_messages( |
| 646 | category_filter=["message", "warning"], with_categories=True |
| 647 | ) |
| 648 | assert list(messages) == [ |
| 649 | ("message", "Hello World"), |
| 650 | ("warning", Markup("<em>Testing</em>")), |
| 651 | ] |
| 652 | return "" |
| 653 | |
| 654 | @app.route("/test_filters_without_returning_categories/") |
| 655 | def test_filters2(): |
| 656 | messages = flask.get_flashed_messages(category_filter=["message", "warning"]) |
| 657 | assert len(messages) == 2 |
nothing calls this directly
no test coverage detected