예제 #1
0
    def test_it_restore_alarm_handler_on_exit(self, signal_mock):
        old_alarm_handler = signal_mock.signal()

        with timeout(2):
            pass

        signal_mock.signal.assert_called_with(signal_mock.SIGALRM,
                                              old_alarm_handler)
예제 #2
0
    def test_it_restore_alarm_handler_on_exit(self, signal_mock):
        old_alarm_handler = signal_mock.signal()

        with timeout(2):
            pass

        signal_mock.signal.assert_called_with(signal_mock.SIGALRM,
                                              old_alarm_handler)
예제 #3
0
    def test_it_does_not_restore_alarm_handler_when_seconds_is_zero(self, signal_mock):
            with timeout(0):
                pass

            signal_mock.signal.assert_not_called()
예제 #4
0
 def test_it_replace_alarm_handler_on_enter(self, signal_mock):
     with timeout(2):
         signal_mock.signal.assert_called_with(signal_mock.SIGALRM,
                                               raise_timeout)
예제 #5
0
 def test_it_does_not_timeout_when_given_time_is_zero(self):
     with self.assertNotRaises(TimeoutError):
         with timeout(0):
             time.sleep(1)
예제 #6
0
 def test_it_does_not_set_alarm_when_seconds_is_zero(self, signal_mock):
         with timeout(0):
             signal_mock.alarm.assert_not_called()
예제 #7
0
 def test_it_does_not_raise_timeout_exception_when_time_is_not_out(self):
     with self.assertNotRaises(TimeoutError):
         with timeout(2):
             time.sleep(1)
예제 #8
0
 def test_it_does_not_replace_alarm_handler_when_seconds_is_none(self, signal_mock):
         with timeout(None):
             signal_mock.signal.assert_not_called()
예제 #9
0
 def test_it_does_not_raise_timeout_exception_when_time_is_not_out(self):
     with self.assertNotRaises(TimeoutError):
         with timeout(2):
             time.sleep(1)
예제 #10
0
 def test_it_does_not_set_alarm_when_seconds_is_none(self, signal_mock):
         with timeout(None):
             signal_mock.alarm.assert_not_called()
예제 #11
0
 def test_it_replace_alarm_handler_on_enter(self, signal_mock):
     with timeout(2):
         signal_mock.signal.assert_called_with(signal_mock.SIGALRM,
                                               raise_timeout)
예제 #12
0
 def test_it_request_alarm_to_be_sent_in_given_seconds_on_enter(self, signal_mock):
     with timeout(2):
         signal_mock.setitimer.assert_called_with(signal_mock.ITIMER_REAL, 2)
예제 #13
0
    def test_it_does_not_restore_alarm_handler_when_seconds_is_zero(self, signal_mock):
            with timeout(0):
                pass

            signal_mock.signal.assert_not_called()
예제 #14
0
 def test_it_does_not_set_alarm_when_seconds_is_zero(self, signal_mock):
         with timeout(0):
             signal_mock.setitimer.assert_not_called()
예제 #15
0
 def test_it_does_not_timeout_when_given_time_is_zero(self):
     with self.assertNotRaises(TimeoutError):
         with timeout(0):
             time.sleep(1)
예제 #16
0
 def test_it_request_alarm_to_be_sent_in_given_seconds_on_enter(self, signal_mock):
     with timeout(2):
         signal_mock.alarm.assert_called_with(2)
예제 #17
0
    def test_it_resets_alarm_on_exit(self, signal_mock):
        with timeout(2):
            pass

        signal_mock.alarm.assert_called_with(0)
예제 #18
0
    def test_it_resets_alarm_on_exit(self, signal_mock):
        with timeout(2):
            pass

        signal_mock.alarm.assert_called_with(0)
예제 #19
0
 def test_it_does_not_replace_alarm_handler_when_seconds_is_none(self, signal_mock):
         with timeout(None):
             signal_mock.signal.assert_not_called()