예제 #1
0
    def test_log_file_has_sub_process_entries(self):
        """ This test documents the alternative: slurp the log results back in
        from the log file and then do the text matches.
        """
        assert applog.delete_log_file_if_exists() == True

        main_logger = applog.MainLogger()

        log_queue = main_logger.log_queue
        sub_proc = multiprocessing.Process(target=self.worker_process,
                                           args=(log_queue, ))
        sub_proc.start()

        time.sleep(1.0)  # make sure the process has enough time to emit

        main_logger.close()

        time.sleep(0.5)  # required to let file creation happen

        log_text = applog.get_text_from_log()

        assert "Top level log configuration" in log_text
        assert "Sub process setup configuration" in log_text
        assert "Sub process debug log info" in log_text
        applog.explicit_log_close()
예제 #2
0
    def test_device_logs_in_file_only(self, simulate_main, caplog, qtbot):
        """ Shows the expected behavior. Demonstrates that the capturelog
        fixture on py.test does not see sub process entries.
        """
        QtTest.QTest.qWaitForWindowShown(simulate_main.form)
        qtbot.wait(1000)

        log_text = applog.get_text_from_log()
        assert "SimulatedPM100 setup" in log_text
        assert "SimulatedPM100 setup" not in caplog.text()
예제 #3
0
    def test_device_logs_in_file_only(self, simulate_main, caplog, qtbot):
        """ Shows the expected behavior. Demonstrates that the capturelog
        fixture on py.test does not see sub process entries.
        """
        QtTest.QTest.qWaitForWindowShown(simulate_main.form)
        qtbot.wait(1000)

        log_text = applog.get_text_from_log()
        assert "SimulatedPM100 setup" in log_text
        assert "SimulatedPM100 setup" not in caplog.text()
예제 #4
0
    def test_log_file_has_entries(self):
        assert applog.delete_log_file_if_exists() == True

        main_logger = applog.MainLogger()
        main_logger.close()

        time.sleep(0.5)  # required to let file creation happen

        log_text = applog.get_text_from_log()

        assert "Top level log configuration" in log_text
        applog.explicit_log_close()
예제 #5
0
    def test_log_file_has_entries(self):
        assert applog.delete_log_file_if_exists() == True

        main_logger = applog.MainLogger()
        main_logger.close()

        time.sleep(0.5)  # required to let file creation happen

        log_text = applog.get_text_from_log()

        assert "Top level log configuration" in log_text
        applog.explicit_log_close()
예제 #6
0
    def test_subprocess_data_collected_and_logged(self, wrapper, caplog):

        # Ensure at least one entry is available on the queue
        result = self.read_while_none(wrapper)

        assert result[0] == 1
        assert result[1] >= 123

        time.sleep(0.5) # Give subprocess log entries time to propagate to file
        log_text = applog.get_text_from_log()

        assert "SimulatedPM100 setup" in log_text
        assert "SimulatedPM100 setup" not in caplog.text()
예제 #7
0
    def test_subprocess_data_collected_and_logged(self, wrapper, caplog):

        # Ensure at least one entry is available on the queue
        result = self.read_while_none(wrapper)

        assert result[0] == 1
        assert result[1] >= 123

        time.sleep(
            0.5)  # Give subprocess log entries time to propagate to file
        log_text = applog.get_text_from_log()

        assert "SimulatedPM100 setup" in log_text
        assert "SimulatedPM100 setup" not in caplog.text()
예제 #8
0
    def test_log_file_has_sub_process_entries(self):
        """ This test documents the alternative: slurp the log results back in
        from the log file and then do the text matches.
        """
        assert applog.delete_log_file_if_exists() == True

        main_logger = applog.MainLogger()

        log_queue = main_logger.log_queue
        sub_proc = multiprocessing.Process(target=self.worker_process, args=(log_queue,))
        sub_proc.start()

        time.sleep(1.0)  # make sure the process has enough time to emit

        main_logger.close()

        time.sleep(0.5)  # required to let file creation happen

        log_text = applog.get_text_from_log()

        assert "Top level log configuration" in log_text
        assert "Sub process setup configuration" in log_text
        assert "Sub process debug log info" in log_text
        applog.explicit_log_close()