(monkeypatch)
| 617 | |
| 618 | |
| 619 | def test_run_cert_import(monkeypatch): |
| 620 | monkeypatch.setitem(sys.modules, "not_here", None) |
| 621 | |
| 622 | # ImportError |
| 623 | with pytest.raises(click.BadParameter): |
| 624 | run_command.make_context("run", ["--cert", "not_here"]) |
| 625 | |
| 626 | with pytest.raises(click.BadParameter): |
| 627 | run_command.make_context("run", ["--cert", "flask"]) |
| 628 | |
| 629 | # SSLContext |
| 630 | ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) |
| 631 | |
| 632 | monkeypatch.setitem(sys.modules, "ssl_context", ssl_context) |
| 633 | ctx = run_command.make_context("run", ["--cert", "ssl_context"]) |
| 634 | assert ctx.params["cert"] is ssl_context |
| 635 | |
| 636 | # no --key with SSLContext |
| 637 | with pytest.raises(click.BadParameter): |
| 638 | run_command.make_context("run", ["--cert", "ssl_context", "--key", __file__]) |
| 639 | |
| 640 | |
| 641 | def test_run_cert_no_ssl(monkeypatch): |
nothing calls this directly
no test coverage detected