Beispiel #1
0
class TestTimer(TestCase):

    def setUp(self):
        self.timer = Timer()
        inject([1, 2, 3], self.timer(null()))

    def test_durations(self):
        self.assertEqual(len(self.timer.durations), 3)

    def test_duration(self):
        """Test the sum of durations."""
        assert_almost_equal(self.timer.duration, sum(self.timer.durations))

    def test_mean(self):
        assert_almost_equal(self.timer.mean, self.timer.duration / len(self.timer.durations))

    def test_reset(self):
        self.timer.reset()
        self.assertEqual(len(self.timer.durations), 0)
Beispiel #2
0
class TestTimer(TestCase):
    def setUp(self):
        self.timer = Timer()

    async def asyncSetUp(self):
        await null(self.timer(async_generate([1, 2, 3])))

    def test_durations(self):
        self.assertEqual(len(self.timer.durations), 3)

    def test_duration(self):
        """Test the sum of durations."""
        assert_almost_equal(self.timer.duration, sum(self.timer.durations))

    def test_mean(self):
        assert_almost_equal(self.timer.mean,
                            self.timer.duration / len(self.timer.durations))

    def test_reset(self):
        self.timer.reset()
        self.assertEqual(len(self.timer.durations), 0)
Beispiel #3
0
 def setUp(self):
     self.timer = Timer()
Beispiel #4
0
 def setUp(self):
     self.timer = Timer()
     inject([1, 2, 3], self.timer(null()))