def _main():
    if sys.argv[1:] == ["test"]:
        for k, v in sorted(globals().items()):
            if not k.startswith("test_"):
                continue
            print("running: %s()" % k)
            v()
        print("ok.")
        sys.exit()
    elif sys.argv[1:] == ["debug_shell"]:
        debug_shell(locals(), globals())
        sys.exit()
    elif sys.argv[1:] == ["debug_shell_exception"]:
        try:
            raise Exception("demo exception")
        except Exception:
            better_exchook(*sys.exc_info(), debugshell=True)
        sys.exit()
    elif sys.argv[1:]:
        print("Usage: %s (test|...)" % sys.argv[0])
        sys.exit(1)
    try:
        x = {1: 2, "a": "b"}
        def f():
            y = "foo"
            x, 42, sys.stdin.__class__, sys.exc_info, y, z
        f()
    except Exception:
        better_exchook(*sys.exc_info())
    try:
        (lambda _x: None)(__name__,
                          42)
    except Exception:
        better_exchook(*sys.exc_info())
    try:
        class Obj:
            def __repr__(self):
                return (
                    "<Obj multi-\n" +
                    "     line repr>")
        obj = Obj()
        assert not obj
    except Exception:
        better_exchook(*sys.exc_info())
    def f1(a):
        f2(a + 1, 2)
    def f2(a, b):
        f3(a + b)
    def f3(a):
        b = ("abc" * 100) + "-interesting"
        a(b)
    try:
        f1(13)
    except Exception:
        better_exchook(*sys.exc_info())
    install()
    finalfail(sys)