def test_unhandled(): def m(args): args.app.retval = Application.UNCAUGHT_EXCEPTION_EXIT raise ValueError("1969") app = Application(m) with pytest.raises(SystemExit): app.run([]) assert app.retval == Application.UNCAUGHT_EXCEPTION_EXIT
def test_atexit(): app = Application(atexit=atexit) with pytest.raises(SystemExit): app.run() assert app.atexit == 2 app = Myapp() with pytest.raises(SystemExit): app.run() assert app.atexit == 3
def test_entryPoints(): app = Application(_main) with pytest.raises(SystemExit): app.run([]) assert app.retval == 2 app = Myapp() with pytest.raises(SystemExit): app.run([]) assert app.retval == 3
def test_pdb(): app = Application(pdb_opt=True) app._main = Mock(side_effect=ValueError) with patch.object(nicfit.app._debugger, "post_mortem") as mock_pm: try: app.run(["--pdb"]) except SystemExit: if sys.version_info[:2] >= (3, 6): mock_pm.assert_called() else: assert mock_pm.call_count != 0 else: pytest.fail("Expected ValueError")
def test_version(capfd): app = Application(version="6.6.6") with pytest.raises(SystemExit): app.run(["--version"]) out, _ = capfd.readouterr() assert out.strip() == "6.6.6"