Пример #1
0
    def test_exit_no_post(self, mock_time, mock_print):
        mock_time.return_value = 456

        stats = ht.events.stats.HoudiniEventStats(None)

        stats._post_report = False

        stats._last_run_time = 0
        stats._total_time = 0
        stats._last_started = 123
        stats._run_count = 0

        exc_type = MagicMock()
        exc_val = MagicMock()
        exc_tb = MagicMock()

        stats.__exit__(exc_type, exc_val, exc_tb)

        run_time = 456-123

        self.assertEqual(stats.last_run_time, run_time)
        self.assertEqual(stats.total_time, run_time)
        self.assertEqual(stats.run_count, 1)

        mock_print.assert_not_called()
Пример #2
0
    def test___exit___no_report(self, init_stats, mocker):
        mock_time = mocker.patch("time.time")
        mock_print = mocker.patch.object(ht.events.stats.HoudiniEventStats,
                                         "print_report")

        stats = init_stats()

        stats._post_report = False

        mock_run_time = mocker.MagicMock(spec=int)
        mock_time.return_value = mock_run_time

        mock_total_time = mocker.MagicMock(spec=int)
        mock_last_run_time = mocker.MagicMock(spec=int)
        mock_last_started = mocker.MagicMock(spec=int)
        mock_run_count = mocker.MagicMock(spec=int)

        stats._last_run_time = mock_last_run_time
        stats._total_time = mock_total_time
        stats._last_started = mock_last_started
        stats._run_count = mock_run_count

        exc_type = mocker.MagicMock()
        exc_val = mocker.MagicMock()
        exc_tb = mocker.MagicMock()

        stats.__exit__(exc_type, exc_val, exc_tb)

        run_time = mock_run_time - mock_last_started

        assert stats.last_run_time == run_time
        assert stats.total_time == mock_total_time + run_time
        assert stats.run_count == mock_run_count + 1

        mock_print.assert_not_called()
Пример #3
0
    def test_exit_no_post(self, mock_time, mock_print):
        mock_time.return_value = 456

        stats = ht.events.stats.HoudiniEventStats(None)

        stats._post_report = False

        stats._last_run_time = 0
        stats._total_time = 0
        stats._last_started = 123
        stats._run_count = 0

        exc_type = MagicMock()
        exc_val = MagicMock()
        exc_tb = MagicMock()

        stats.__exit__(exc_type, exc_val, exc_tb)

        run_time = 456-123

        self.assertEqual(stats.last_run_time, run_time)
        self.assertEqual(stats.total_time, run_time)
        self.assertEqual(stats.run_count, 1)

        mock_print.assert_not_called()