(app, client)
| 6 | |
| 7 | |
| 8 | def test_custom_converters(app, client): |
| 9 | class ListConverter(BaseConverter): |
| 10 | def to_python(self, value): |
| 11 | return value.split(",") |
| 12 | |
| 13 | def to_url(self, value): |
| 14 | base_to_url = super().to_url |
| 15 | return ",".join(base_to_url(x) for x in value) |
| 16 | |
| 17 | app.url_map.converters["list"] = ListConverter |
| 18 | |
| 19 | @app.route("/<list:args>") |
| 20 | def index(args): |
| 21 | return "|".join(args) |
| 22 | |
| 23 | assert client.get("/1,2,3").data == b"1|2|3" |
| 24 | |
| 25 | with app.test_request_context(): |
| 26 | assert url_for("index", args=[4, 5, 6]) == "/4,5,6" |
| 27 | |
| 28 | |
| 29 | def test_context_available(app, client): |
nothing calls this directly
no test coverage detected