fps計算方法および顔検出方法の変更に伴いtestの内容を変更
This commit is contained in:
1 parent
5d1ecc6883
commit
048bad7065
2 files changed
+9
-7
No files matched your search
@@ -6,25 +6,27 @@ from src.fps_counter import FPSCounter
|
||||
def test_initial_and_tick_and_average(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
times = iter([1.0, 1.5, 1.75])
|
||||
monkeypatch.setattr("src.fps_counter.time.perf_counter", lambda: next(times))
|
||||
counter = FPSCounter(2)
|
||||
assert counter.current_fps == counter.average_fps == 0.0
|
||||
counter = FPSCounter(2, 2)
|
||||
assert counter.current_fps == counter.recent_average_fps == 0.0
|
||||
assert counter.tick() == 0.0
|
||||
assert counter.tick() == pytest.approx(2.0)
|
||||
assert counter.tick() == pytest.approx(4.0)
|
||||
assert counter.average_fps == pytest.approx(3.0)
|
||||
assert counter.sample_count == 1
|
||||
assert counter.average_fps == pytest.approx(4.0)
|
||||
assert counter.recent_average_fps == pytest.approx(4.0)
|
||||
|
||||
|
||||
def test_reset(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
times = iter([1.0, 2.0])
|
||||
monkeypatch.setattr("src.fps_counter.time.perf_counter", lambda: next(times))
|
||||
counter = FPSCounter(3)
|
||||
counter = FPSCounter(3, 0)
|
||||
counter.tick()
|
||||
counter.tick()
|
||||
counter.reset()
|
||||
assert counter.current_fps == counter.average_fps == 0.0
|
||||
assert counter.current_fps == counter.recent_average_fps == 0.0
|
||||
assert counter.sample_count == 0
|
||||
|
||||
|
||||
def test_invalid_window() -> None:
|
||||
with pytest.raises(ValueError):
|
||||
FPSCounter(0)
|
||||
FPSCounter(0, 0)
|
||||
Reference in new issue
Block a user