Example #1
0
    def test_timestamp(self):
        """ test_timestamp
        Test 6 seconds, with a unix timestamp
        """
        toTime = time.time() + 6
        start = time.time()
        pause.until(toTime)

        # True if it came within 0.1 of a second
        end = time.time()
        diff = int(end - start)
        self.assertEqual(diff, 6)
Example #2
0
    def test_datetime(self):
        """ test_datetime
        Test 7 seconds, with a datetime object
        """
        startDate = datetime.now()
        toDate = startDate + timedelta(seconds=7)
        pause.until(toDate)
        now = datetime.now()

        # True if at least 7 seconds has passed
        diff = now - startDate
        self.assertEqual(diff.seconds, 7)
Example #3
0
    def test_timestamp(self):
        """ test_timestamp
        Test 6 seconds, with a unix timestamp
        """
        toTime = time.time() + 6
        start = time.time()
        pause.until(toTime)

        # True if it came within 0.1 of a second
        end = time.time()
        diff = int(end - start)
        self.assertEqual(diff, 6)
Example #4
0
    def test_datetime(self):
        """ test_datetime
        Test 7 seconds, with a datetime object
        """
        startDate = datetime.now()
        toDate = startDate + timedelta(seconds=7)
        pause.until(toDate)
        now = datetime.now()

        # True if at least 7 seconds has passed
        diff = now - startDate
        self.assertEqual(diff.seconds, 7)
Example #5
0
    def test_timezone(self):
        """ test_datetime
        Test 7 seconds, with a datetime object
        """
        if sys.version_info[0] >= 3:
            from datetime import timezone
			# Apply a timezone offset, Line Islands Time for fun
            startDate = datetime.now(timezone(timedelta(hours=14), 'LINT'))
            toDate = startDate + timedelta(seconds=7)
            pause.until(toDate)
            now = datetime.now(timezone.utc)

            # True if at least 7 seconds has passed
            diff = now - startDate
            self.assertEqual(diff.seconds, 7)
Example #6
0
    def test_past(self):
        """ test_past
        Test a time that has already passed
        """

        # Using seconds()
        start = time.time()
        pause.seconds(-5)
        end = time.time()
        self.assertEqual(int(end - start), 0)

        # Using until()
        start = time.time()
        pause.until(time.time() - 10)
        end = time.time()
        self.assertEqual(int(end - start), 0)
Example #7
0
    def test_past(self):
        """ test_past
        Test a time that has already passed
        """

        # Using seconds()
        start = time.time()
        pause.seconds(-5)
        end = time.time()
        self.assertEqual(int(end - start), 0)

        # Using until()
        start = time.time()
        pause.until(time.time() - 10)
        end = time.time()
        self.assertEqual(int(end - start), 0)