Exemplo n.º 1
0
    def testLoggingOptions(self):
        import logging
        from eyed3 import log

        with open("/dev/null", "w") as devnull:
            with RedirectStdStreams(stderr=devnull):
                try:
                    _ = main.parseCommandLine(["-l", "critical"])
                    assert_equal(log.getEffectiveLevel(), logging.CRITICAL)

                    _ = main.parseCommandLine(["--log-level=error"])
                    assert_equal(log.getEffectiveLevel(), logging.ERROR)

                    _ = main.parseCommandLine(["-l", "warning:NewLogger"])
                    assert_equal(
                            logging.getLogger("NewLogger").getEffectiveLevel(),
                            logging.WARNING)
                    assert_equal(log.getEffectiveLevel(), logging.ERROR)
                except SystemExit:
                    assert_false("Unexpected")

                try:
                    _ = main.parseCommandLine(["--log-level=INVALID"])
                    assert_false("Invalid log level, an Exception expected")
                except SystemExit:
                    pass
Exemplo n.º 2
0
    def testLoggingOptions(self):
        import logging
        from eyed3 import log

        with open("/dev/null", "w") as devnull:
            with RedirectStdStreams(stderr=devnull):
                try:
                    _ = main.parseCommandLine(["-l", "critical"])
                    assert log.getEffectiveLevel() == logging.CRITICAL

                    _ = main.parseCommandLine(["--log-level=error"])
                    assert log.getEffectiveLevel() == logging.ERROR

                    _ = main.parseCommandLine(["-l", "warning:NewLogger"])
                    assert (
                        logging.getLogger("NewLogger").getEffectiveLevel() ==
                        logging.WARNING
                    )
                    assert log.getEffectiveLevel() == logging.ERROR
                except SystemExit:
                    assert not("Unexpected")

                try:
                    _ = main.parseCommandLine(["--log-level=INVALID"])
                    assert not("Invalid log level, an Exception expected")
                except SystemExit:
                    pass