コード例 #1
0
def test_logging_capture(caplog: LogCaptureFixture):
    logger = logging.getLogger(__name__)

    # make a random INFO log and ensure it passes decorator
    info_text = "SOME INFO"
    logger.info(info_text)
    with assert_log_emitted(caplog, logger.name, logging.INFO, info_text):
        pass
コード例 #2
0
def test_logging_capture_failure(caplog: LogCaptureFixture):
    logger = logging.getLogger(__name__)

    # make a random INFO log
    logger.info("SOME INFO")

    # test for string in log that wasn't emitted
    with pytest.raises(AssertionError):
        with assert_log_emitted(caplog, logger.name, logging.INFO, "NONONO"):
            pass
コード例 #3
0
def test_deprecated_pickle_deserialisation(caplog: LogCaptureFixture):
    def pickle_serialise_tracker(_tracker):
        # mocked version of TrackerStore.serialise_tracker() that uses
        # the deprecated pickle serialisation
        import pickle

        dialogue = _tracker.as_dialogue()

        return pickle.dumps(dialogue)

    store, tracker = _tracker_store_and_tracker_with_slot_set()

    serialised = pickle_serialise_tracker(tracker)

    # deprecation warning should be emitted
    with assert_log_emitted(caplog, rasa.core.tracker_store.logger.name,
                            logging.WARNING, "DEPRECATION"):
        assert tracker == store.deserialise_tracker(
            UserMessage.DEFAULT_SENDER_ID, serialised)